private bool InsertBackbound() { bool bres = false; string sql = String.Format("Insert into T_Backbound (BackboundID, PONo, BackDate, Sales, Customer, Status ,Remark ) " + "Values('{0}','{1}','{2}','{3}','{4}' ,'{5}','{6}')", txtBackboundNo.Text, txtPONo.Text.Trim().Replace("'", "''"), dateOrder.DateTime.ToString("yyyy-MM-dd"), cboSales.Text.Trim().Replace("'", "''"), cboCustomer.Text.Trim().Replace("'", "''"), DealStatus.No, txtMemo.Text.Replace("'", "''")); bres = Database.ExecuteSQL(sql, "FrmBackbound-InsertBackbound") == 1 ? true : false; if (bres) { newBackBound = new BackBound(); newBackBound.BackboundID = txtBackboundNo.Text; newBackBound.PONo = txtPONo.Text; newBackBound.Sales = cboSales.Text.Trim(); newBackBound.Customer = cboCustomer.Text.Trim(); newBackBound.Status = DealStatus.No; newBackBound.OrderDate = dateOrder.DateTime.ToString("yyyy-MM-dd"); newBackBound.Memo = txtMemo.Text; } return(bres); }
public void InsertBackbound(int pos, BackBound bound) { DataRow dr = dataTable.NewRow(); dr["BackboundID"] = bound.BackboundID; dr["PONo"] = bound.PONo; dr["BackDate"] = bound.OrderDate; dr["Sales"] = bound.Sales; dr["Customer"] = bound.Customer; dr["Status"] = bound.Status; dr["Remark"] = bound.Memo; dataTable.Rows.InsertAt(dr, pos); }
private void btnOK_Click(object sender, EventArgs e) { if (bound == null) { bound = new BackBound(); } bound.PONo = txtPONo.Text.Trim(); bound.OrderDate = dateOrder.DateTime.ToString("yyyy-MM-dd"); bound.Customer = cboCustomer.Text.Trim(); bound.Sales = cboSales.Text.Trim(); bound.Memo = txtMemo.Text; DialogResult = DialogResult.OK; this.Close(); }
private void mnuMasterEditBackbound_Click(object sender, EventArgs e) { string boundID = masterView.GetFocusedRowCellValue("BackboundID").ToString(); string backDate = masterView.GetFocusedRowCellValue("BackDate").ToString(); string poNo = masterView.GetFocusedRowCellValue("PONo").ToString(); string customer = masterView.GetFocusedRowCellValue("Customer").ToString(); BackBound bound = new BackBound(); bound.BackboundID = boundID; bound.PONo = poNo; bound.OrderDate = backDate; bound.Customer = customer; FrmEditBackbound dlg = new FrmEditBackbound(); dlg.BackboundID = boundID; dlg.BackboundItem = bound; if (DialogResult.Cancel == dlg.ShowDialog()) { return; } masterView.SetFocusedRowCellValue("BackDate", bound.OrderDate); masterView.SetFocusedRowCellValue("PONo", bound.PONo); masterView.SetFocusedRowCellValue("Customer", bound.Customer); masterView.SetFocusedRowCellValue("Sales", bound.Sales); masterView.SetFocusedRowCellValue("Remark", bound.Memo); string sql = String.Format("update T_Backbound Set PONo = '{0}' , BackDate = '{1}',Sales = '{2}' ,Customer = '{3}', Remark = '{4}' Where BackboundID = '{5}' ", bound.PONo, bound.OrderDate, bound.Sales.Replace("'", "''"), bound.Customer.Replace("'", "''"), bound.Memo.Replace("'", "''"), boundID); Database.ExecuteSQL(sql, "FrmBackbound-mnuMasterEditBackbound_Click"); }
static private BackBound GetBackBound(string id) { BackBound bound = new BackBound(); string sql = String.Format("Select PONo, BackDate, Customer, status From T_Backbound " + " where BackboundID = '{0}' ", id); DataTable dt = Database.Select(sql); if (dt == null || dt.Rows.Count == 0) { return(bound); } DataRow dr = dt.Rows[0]; int col = 0; bound.BackboundID = id; bound.PONo = dr[col++].ToString(); bound.OrderDate = dr[col++].ToString(); bound.Customer = dr[col++].ToString(); bound.Status = dr[col++].ToString(); return(bound); }
static public void ExportDetail(GridView detailView, string boundID, string fileName) { string templetFile = Application.StartupPath + "\\templet\\ReturnTemplet.xls"; // string exportFile = AppConfig.GetTempDirectory() + Database.GetGlobalKey() + ".xls"; FileStream file = new FileStream(templetFile, FileMode.Open, FileAccess.Read); HSSFWorkbook hssfworkbook = new HSSFWorkbook(file); ISheet sheet = hssfworkbook.GetSheet("Sheet1"); BackBound bound = GetBackBound(boundID); #region 导出退货单属性 sheet.GetRow(1).GetCell(34).SetCellValue(bound.OrderDate); sheet.GetRow(2).GetCell(34).SetCellValue(bound.PONo); sheet.GetRow(3).GetCell(34).SetCellValue(bound.Sales); #endregion //导出数据 GetData(sheet, detailView); //保存文件 sheet.ForceFormulaRecalculation = true; using (FileStream filess = File.OpenWrite(fileName)) { hssfworkbook.Write(filess); filess.Close(); filess.Dispose(); } //file.Close(); //file.Dispose(); GC.Collect(); }