📄 frmreturn.cs
字号:
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(800, 389);
this.Controls.Add(this.btnShowRetLog);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.btnReturn);
this.Controls.Add(this.chlProductList);
this.Controls.Add(this.dbgBillInfo);
this.Controls.Add(this.grpReturn);
this.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Name = "frmReturn";
this.Text = "退货管理";
this.Closing += new System.ComponentModel.CancelEventHandler(this.frmReturn_Closing);
this.Load += new System.EventHandler(this.frmReturn_Load);
this.grpReturn.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dbgBillInfo)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void btnExit_Click(object sender, System.EventArgs e)
{
frmMainMenu.varRtnMgmt = 0;
this.Close ();
}
private void frmReturn_Load(object sender, System.EventArgs e)
{
//comboBox1.SelectedIndex=0;
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
try
{
//if the billid textbox is not null
if(this.txtBillId.Text!="")
{
searchValue[0] = this.txtBillId.Text;
}
else
{
//Setting the first array to null
searchValue[0] = "";
}
//if the date criteria is not null
if (dateSelected)
{
searchValue[1] = this.dtpBillDate.Value.ToShortDateString();
}
else
{
this.dtpBillDate.Enabled =false;
searchValue[1] = "";
}
if(this.cboDateCriteria.Enabled == true)
{
searchValue[2] = this.cboDateCriteria.Text;
}
else
searchValue[2] = "";
//Create an Object of SalesAdminManagement
SalesAdminManagement salesadmMgmt = new SalesAdminManagement();
//Counting the number of values fetched from the database
// and specifying the datasource
if(salesadmMgmt.FetchReturnDetails(searchValue).Rows.Count >0)
{
this.dbgBillInfo.DataSource = salesadmMgmt.FetchReturnDetails(searchValue);
flag = true;
this.btnReturn.Enabled = true;
}
else
{
// If No records are fetched clearing the Datagrid and setting
// the datasource as null
this.dbgBillInfo.DataSource = null;
MessageBox.Show("未捕获到任何记录");
}
}
catch(Exception excep)
{
MessageBox.Show ("发生错误 "+excep.Message.ToString ());
}
}
private void dtpBillDate_ValueChanged(object sender, System.EventArgs e)
{
this.txtBillId.Enabled = false;
this.cboDateCriteria.Enabled = false;
dateSelected=true;
}
private void txtBillId_TextChanged(object sender, System.EventArgs e)
{
if (this.txtBillId.Text=="")
{
dtpBillDate.Enabled =true;
cboDateCriteria.Enabled =true;
}
else
{
dtpBillDate.Enabled =false;
cboDateCriteria.Enabled =false;
}
}
private void btnReturn_Click(object sender, System.EventArgs e)
{
try
{
//match against items from the checked list box and get the ids of the selected products.
int index = 0;
prodId = new string[this.chlProductList.Items.Count];
for(int ctr2 = 0; ctr2 < this.chlProductList.Items.Count; ctr2++)
{
if(this.chlProductList.GetItemChecked(ctr2))
{
this.prodId[index] = productInfo[ctr2,1];
index++;
}
}
SalesAdminManagement salesadmMgmt = new SalesAdminManagement ();
this.logFilePath= salesadmMgmt.ReturnProducts(this.billNo,this.prodId);
if (this.logFilePath != null)
{
MessageBox.Show ("产品已退回,购买记录已从帐单删除,现有数量已更新");
MessageBox.Show("日志文件也已生成!");
dbgBillInfo.Refresh ();
this.btnShowRetLog.Enabled = true;
//populate chl prod box again
populateCheckedListBox();
}
}
catch(Exception excep)
{
MessageBox.Show ("发生错误 "+excep.Message.ToString ());
}
}
private void btnShowRetLog_Click(object sender, System.EventArgs e)
{
if (this.logFilePath != null)
{
frmLogFile logFileForm = new frmLogFile(this.logFilePath);
logFileForm.MdiParent = this.ParentForm;
logFileForm.Show();
}
}
private void cboDateCriteria_DropDown(object sender, System.EventArgs e)
{
this.dtpBillDate.Enabled =false;
this.txtBillId.Enabled =false;
}
private void dbgBillInfo_CurrentCellChanged(object sender, System.EventArgs e)
{
populateCheckedListBox();
}
private void frmReturn_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
frmMainMenu.varRtnMgmt = 0;
}
private void txtBillId_MouseHover(object sender, System.EventArgs e)
{
this.tipReturns.SetToolTip(this.txtBillId,"输入帐单标识用来搜索...(可选)");
}
private void dtpBillDate_MouseHover(object sender, System.EventArgs e)
{
this.tipReturns.SetToolTip(this.dtpBillDate,"输入帐单日期用来搜索...(可选)");
}
private void cboDateCriteria_MouseHover(object sender, System.EventArgs e)
{
this.tipReturns.SetToolTip(this.cboDateCriteria,"输入日期标准用来搜索...(可选)");
}
private void btnReturn_MouseHover(object sender, System.EventArgs e)
{
this.tipReturns.SetToolTip(this.btnReturn,"点击这里退货");
}
private void btnShowRetLog_MouseHover(object sender, System.EventArgs e)
{
this.tipReturns.SetToolTip(this.btnShowRetLog,"点击这里显示退货日志文件");
}
private void chlProductList_MouseHover(object sender, System.EventArgs e)
{
this.tipReturns.SetToolTip(this.chlProductList ,"选择要退货的产品");
}
private void populateCheckedListBox()
{
try
{
//check if checklistbox is already populated
if (chlProductList.Items.Count >0)
chlProductList.Items.Clear();
//check if grid has data
if (flag)
{
//retrieve the details of the selected bill.
DataTable dtBill = (DataTable)dbgBillInfo.DataSource;
DataRow drBill = dtBill.Rows[dbgBillInfo.CurrentRowIndex];
billNo = int.Parse (drBill["BillNo"].ToString()) ;
string str = "select productname,productid from products where productid in (select productid from stock where stockid in (select stockid from billdetails where billno=" +this.billNo+")) order by productid";
DataConnection.commnd.CommandText =str;
OleDbDataReader reader= DataConnection.commnd.ExecuteReader ();
int ctr = 0;
while (reader.Read())
{
chlProductList.Items.Add(reader.GetString (0));
productInfo[ctr,0]=reader.GetString(0);
productInfo[ctr,1]=reader.GetString(1);
ctr++;
}
reader.Close();
}
}
catch(Exception excep)
{
MessageBox.Show ("发生错误 "+excep.Message.ToString ());
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -