2025-03-27 15:05:14 +08:00

130 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using SuperMap.RealEstate.Windows.Controls.NetSocket;
namespace InventoryTool
{
public partial class Form3 : Form
{
string strConnection = string.Empty;
OleDbConnection con = null;
private string _shop_id;
private DateTime _checkDate;
public string Shop_id
{
get { return _shop_id; }
set { Shop_id = value; }
}
public DateTime CheckDate
{
get { return _checkDate; }
set { CheckDate = value; }
}
public Form3()
{
string filePath = Path.GetFullPath("InventoryData.mdb");
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Persist Security Info=False";
con = new OleDbConnection(strConnection);
InitializeComponent();
ArrayList listshopID = new ArrayList();
con.Open();
try
{
string selectSql = "SELECT * FROM SHOPMESSAGE WHERE BUSINESSTYPE LIKE '%1000%' ORDER BY SERVERPARTSHOP_ID ASC";
OleDbCommand dc = new OleDbCommand(selectSql, con);
OleDbDataReader dr = dc.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
listshopID.Add(dr["SHOPNAME"].ToString());
}
listshopID.Insert(0, "请选择门店");
cobshopname.DataSource = listshopID;
}
con.Close();
}
catch (Exception ex)
{
LogHelper.WriteServiceLog(ex.Message);
con.Close();
}
}
private void cobshopname_SelectedIndexChanged_1(object sender, EventArgs e)
{
try
{
if (cobshopname.Text != "请选择门店")
{
string selectdate = "SELECT DISTINCT(CheckDate)AS CheckDate FROM CommodityInventory WHERE SERVERPARTSHOP_ID = (SELECT SERVERPARTSHOP_ID FROM SHOPMESSAGE WHERE SHOPNAME = '" + cobshopname.Text + "') ORDER BY CheckDate DESC";
con.Open();
cobcheckdate.Items.Clear();
OleDbCommand com = new OleDbCommand(selectdate, con);
OleDbDataReader rd = com.ExecuteReader();
if (rd.HasRows)
{
while (rd.Read())
{
cobcheckdate.Items.Add(rd["CheckDate"].ToString());
}
}
con.Close();
cobcheckdate.SelectedIndex = 0;
}
}
catch(Exception ex)
{
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (cobshopname.Text == "请选择门店")
{
MessageBox.Show("请先选择门店!");
}
else if (cobcheckdate.Text == "")
{
MessageBox.Show("当前选择的门店没有盘点记录,请重新选择!");
}
else
{
string selectdate = "SELECT SERVERPARTSHOP_ID FROM SHOPMESSAGE WHERE SHOPNAME = '" + cobshopname.Text + "'";
con.Open();
OleDbCommand com = new OleDbCommand(selectdate, con);
OleDbDataReader rd = com.ExecuteReader();
if (rd.HasRows)
{
if (rd.Read())
{
_shop_id = rd["SERVERPARTSHOP_ID"].ToString();
}
}
con.Close();
_checkDate = Convert.ToDateTime(cobcheckdate.Text);
this.DialogResult = DialogResult.OK;
this.Close();
}
}
catch (Exception ex)
{
LogHelper.WriteServiceLog(ex.Message);
con.Close();
}
}
}
}