private void FormLoad(object sender, EventArgs e) { #region 加载主窗体事件 if (opState == OpState.Add) { model = new Mould(); model.dtEquipment = dal.GetEqDetails(""); model.MCId = modelC.MCId; model.cMCCode = modelC.Code; model.cMCName = modelC.Name; model.cMaker = Information.UserInfo.cUser_Name; lblModuleTitle.Text = "新增 - " + this.lblModuleTitle.Text; } else if (opState == OpState.Update) { model = dal.Get(MId); model.cModifier = Information.UserInfo.cUser_Name; oldMCode = model.cMCode; lblModuleTitle.Text = "编辑 - " + this.lblModuleTitle.Text; } UIControl.SetStatus(tab_Main.AttachedControl, opState); UIBinding <Mould> .UIDataBinding(tab_Main.AttachedControl, model); #endregion }
private void btnSave_Click(object sender, EventArgs e) { DataTable pdfTable = new DataTable(); string[] headers = { "Chase No.", "Item Text", "Part No.", "Ringi", "Vendor" }; foreach (string header in headers) { pdfTable.Columns.Add(header); } foreach (SavedList item in savedList) { string itemText = Mould.GetItemText(item.ChaseNo); string vendorName = Vendor.GetVendorName(item.Vendor); string storedVendor = item.Vendor + " " + vendorName; string query = string.Format("update TB_MOULD_MAIN set m_ringi = '{0}' where m_chaseno = '{1}'", item.ChaseNo, item.Ringi); DataService.GetInstance().ExecuteNonQuery(query); pdfTable.Rows.Add(item.ChaseNo, itemText, item.PartNo, item.Ringi, storedVendor); } PdfUtil.ExportPdf(pdfTable); MessageBox.Show("Record has been saved."); this.LoadRingi(txtSearch.Text); this.LoadData(txtSearchItem.Text); }
private void tsbtnRequest_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dgvDisposal.SelectedRows) { string vendor = row.Cells[0].Value.ToString(); string vendorName = row.Cells[1].Value.ToString(); string chaseNo = row.Cells[2].Value.ToString(); string mouldNo = row.Cells[3].Value.ToString(); string partNo = row.Cells[4].Value.ToString(); string rev = row.Cells[5].Value.ToString(); string fixedAsset = Mould.GetFixedAssetCode(chaseNo); string saveFa = fixedAsset == "" ? "-" : fixedAsset; string query = string.Format("insert into TB_MOULD_DISPOSAL (md_type, md_status, md_chaseno, md_mouldno" + ", md_itemcode, md_fixedasset, md_vendor, md_vendorname) values ('{0}', N'{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')", "-----", "調整依賴中", chaseNo, mouldNo, partNo, saveFa, vendor, vendorName); DataService.GetInstance().ExecuteNonQuery(query); string updateText = string.Format("update TB_MOULD_MAIN set mm_status_code = 'DP' where mm_chaseno = '{0}'", chaseNo); DataService.GetInstance().ExecuteNonQuery(updateText); } MessageBox.Show("Record has been saved. Please go to Processing view for further operations."); this.LoadData(txtSearch.Text); }
public void TestRemovePartB() { using (var fs = File.Open("./template.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var mould = new Mould(fs)) { var removal = new Removal(); removal.Add("PartBStart", "PartBEnd"); mould.RemoveSection(removal); mould.Save(); } }
private void ReturnData(object sender, EventArgs e) { #region 新增业务数据 string mid = (string)dtDetail.Rows[sGrid.CurrentRow.Index]["MId"]; Result = dal.Get(mid); DialogResult = DialogResult.OK; #endregion }
public void TestReplace() { using (var fs = File.Open("./template.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var mould = new Mould(fs)) { var replacement = new Replacement(); replacement.Add("Field1", "Field1BlaBlaBla111"); replacement.Add("Field2", "Field2BlaBlaBla222"); replacement.Add("Field3", "Field3BlaBlaBla333"); mould.ReplaceField(replacement); mould.Save(); } }
public bool Update(Mould model) { #region 更新 model.dModifyDate = DateTime.Now.Date; StringBuilder sb = new StringBuilder(); sb.Append("update Mould set MCId = @MCId, cMCode = @cMCode, cMName = @cMName, "); sb.Append(" Points = @Points, bStop = @bStop, cModifier = @cModifier,"); sb.Append("dModifyDate = @dModifyDate, bGroup = @bGroup where MId = @MId \r\n"); return(conn.Execute(sb.ToString(), model) > 0); #endregion }
public bool Add(Mould model) { #region 新增 model.MId = Guid.NewGuid().ToString(); model.dCreateDate = DateTime.Now.Date; StringBuilder sb = new StringBuilder(); sb.Append("insert into Mould(MId, MCId, cMCode, cMName, Points, bStop, cMaker, bGroup, dCreateDate)"); sb.Append(" values(@MId, @MCId, @cMCode, @cMName, @Points, @bStop, @cMaker, @bGroup, @dCreateDate)"); return(conn.Execute(sb.ToString(), model) > 0); #endregion }
private void FormLoad(object sender, EventArgs e) { #region 加载主窗体事件 model = dal.Get(MId); this.InitColumns(); UIBinding <Mould> .UIDataBinding(panelEx1, model); Grid.DataSource = model.dtEquipment.DefaultView; model.dtEquipment.ColumnChanging += DtEquipment_ColumnChanging; #endregion }
private void MenuItemClicked(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; string tag = item.Tag.ToString(); string chaseNo = dgvMain.SelectedRows[0].Cells[1].Value.ToString(); string vendor = dgvMain.SelectedRows[0].Cells[2].Value.ToString(); string mpa = dgvMain.SelectedRows[0].Cells[14].Value.ToString(); string fixedAsset = dgvMain.SelectedRows[0].Cells[15].Value.ToString(); string itemText = Mould.GetItemText(chaseNo); FaCancelForm form = new FaCancelForm(tag, fixedAsset, vendor, chaseNo, itemText, mpa); form.ShowDialog(); }
public FaDisposalForm(string fixedAsset, string vendor, string chaseNo) { InitializeComponent(); _fixedAsset = fixedAsset; _vendor = vendor; _chaseNo = chaseNo; _itemText = Mould.GetItemText(chaseNo); _mpa = Mould.GetMpa(chaseNo); lstAttachment = new List <string>(); txtSection.Text = GlobalService.IPO1st; txtDivision.Text = GlobalService.IPO2nd; }
public void TestReplaceAndRemovePartB() { using (var fs = File.Open("./template.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var mould = new Mould(fs)) { var removal = new Removal(); removal.Add("PartBStart", "PartBEnd"); mould.RemoveSection(removal); var replacement = new Replacement(); replacement.Add("Field1", "Field1BlaBlaBla111"); replacement.Add("Field2", "Field2BlaBlaBla222"); replacement.Add("Field3", "Field3BlaBlaBla333"); mould.ReplaceField(replacement); mould.Save(); } }
private void btnPreview_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dgvSearch.SelectedRows) { string mouldNo = row.Cells[0].Value.ToString(); string partNo = row.Cells[1].Value.ToString(); string rev = row.Cells[2].Value.ToString(); string vendor = row.Cells[3].Value.ToString(); string chaseNo = row.Cells[5].Value.ToString(); string model = Mould.GetModel(chaseNo); string amount = Mould.GetAmount(chaseNo); string remarks = Mould.GetRemarks(chaseNo); string pcs = Mould.GetPcs(chaseNo); dgvPreview.Rows.Add(Properties.Resources.cross, mouldNo, partNo, rev, vendor, _vendor, model, amount, remarks, pcs, chaseNo); } }
public void TestReplaceWithStyle() { using (var fs = File.Open("./template.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var mould = new Mould(fs)) { var replacement = new Replacement(); var style = new ReplaceStyle() { StrikeThrough = true, Bold = true, FontSize = 22 }; replacement.Add("Field1", "Field1BlaBlaBla111", style); replacement.Add("Field2", "Field2BlaBlaBla222"); replacement.Add("Field3", "Field3BlaBlaBla333"); mould.ReplaceField(replacement); mould.Save(); } }
private void btnNext_Click(object sender, EventArgs e) { string vendor = txtVendor.Text.Trim(); string partno = txtPartno.Text.Trim(); string rev = txtRev.Text.Trim().Length == 1 ? "0" + txtRev.Text.Trim() : txtRev.Text.Trim(); string model = txtModel.Text.Trim(); string remarks = txtRemarks.Text; int newNo = Convert.ToInt32(nudnew.Value); int modifyNo = Convert.ToInt32(nudmodify.Value); int pcs = Convert.ToInt32(nudPcs.Value); string pbase = cbBase.SelectedItem.ToString(); string oem = txtOem.Text; string pgroup = cbPgroup.SelectedItem.ToString(); if (!QuotationUtil.IsLengthValid(partno)) { MessageBox.Show("Invalid Part No. Length"); return; } if (string.IsNullOrEmpty(rev)) { MessageBox.Show("Please input Rev"); return; } if (partno.Length == 12 || partno.Length == 15) { if (string.IsNullOrEmpty(model)) { MessageBox.Show("Please input Model"); return; } } else if (partno.Length == 8) { model = partno.Substring(0, 3); } else { if (partno.StartsWith("1")) { model = partno.Substring(3, 3); } else { model = partno.Substring(2, 3); } } if (oem != "") { if (oem.Length == 1) { oem = "0" + oem; } if (!Oem.IsOemValid(oem)) { MessageBox.Show("Please input valid OEM"); return; } } string currency = Vendor.GetVendorCurrency(vendor); if (newNo != 0) { string mouldno = Mould.IsPartNoExist(partno) ? "K" + Mould.GetLatestMouldNo(partno) : "K" + partno + "01"; dgvInput.Rows.Add(Properties.Resources.cross, mouldno, partno, rev, vendor, model, "New", "", currency, "0", "---", remarks, "---", pcs, oem, pbase, pgroup); for (int i = 1; i < newNo; i++) { int rowIndex = dgvInput.Rows.Count - 1; string rMould = dgvInput.Rows[rowIndex].Cells[1].Value.ToString(); int mId = Convert.ToInt32(rMould.Substring(rMould.Length - 2)); int cmId = mId + 1; mouldno = "K" + partno + cmId.ToString("00"); dgvInput.Rows.Add(Properties.Resources.cross, mouldno, partno, rev, vendor, model, "New", "", currency, "0", "---", remarks, "---", pcs, oem, pbase, pgroup); } } if (modifyNo != 0) { for (int i = 0; i < modifyNo; i++) { dgvInput.Rows.Add(Properties.Resources.cross, "", partno, rev, vendor, model, "Modify", "", currency, "0", "---", remarks, "---", pcs, oem, pbase, pgroup); } } }
private void btnSave_Click(object sender, EventArgs e) { if (CheckDataList().Count > 0) { foreach (int index in CheckDataList()) { dgvInput.Rows[index].DefaultCellStyle.BackColor = Color.Red; dgvInput.Rows[index].DefaultCellStyle.ForeColor = Color.White; } return; } foreach (DataGridViewRow row in dgvInput.Rows) { string mouldNo = row.Cells[1].Value.ToString(); string partNo = row.Cells[2].Value.ToString(); string rev = row.Cells[3].Value.ToString(); string vendor = row.Cells[4].Value.ToString(); string model = row.Cells[5].Value.ToString(); string div = row.Cells[6].Value.ToString(); string mouldCode = row.Cells[7].Value.ToString(); string currency = row.Cells[8].Value.ToString(); string amount = row.Cells[9].Value.ToString(); string mpa = row.Cells[10].Value == "Yes" ? "True" : "False"; string remarks = row.Cells[11].Value.ToString(); string modify = row.Cells[12].Value == "Yes" ? "True" : "False"; string pcs = row.Cells[13].Value.ToString(); string oem = row.Cells[14].Value.ToString(); string pbase = row.Cells[15].Value.ToString(); string pgroup = row.Cells[16].Value.ToString(); string chaseno = Mould.GetLatestChaseNo(); string projectText = partNo + "-" + rev; string request = partNo + rev; string itemText = mpa == "Yes" ? mouldNo + "MP+" + mouldCode + "+" + div + "*" : mouldNo + "MP+" + mouldCode + "+" + div; string instock50 = mpa == "Yes" ? "Yes" : "#N/A"; string quantity = mpa == "Yes" ? "2" : "1"; string accountCode = oem != "" ? Oem.GetAccountCode(oem) : ""; string costCentre = oem != "" ? Oem.GetCostCentre(oem) : ""; decimal cAmount = currency == "JPY" ? Convert.ToDecimal(amount) * Convert.ToDecimal(Amount.GetMonthlyJpyRate(DateTime.Today.ToString("yyyy"), DateTime.Today.ToString("MM"))) : Amount.AmountWithRate(currency, amount); string amountHkd = cAmount.ToString("#.##"); cAmount = cAmount / Convert.ToInt32(pcs); string category = "A"; string status = ""; if (cAmount < 10000) { category = "K"; status = cAmount == 0 ? "K" : "U"; } else { category = (mouldCode.StartsWith("8") && mouldCode != "8") || (oem != "") ? "K" : "A"; status = (mouldCode.StartsWith("8") && mouldCode != "8") || (oem != "") ? "U" : "F"; } string po = div == "TM" ? chaseno.Replace("MS", "TM") : ""; string created = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string createdby = GlobalService.Owner; string query = string.Format("insert into TB_MOULD_MAIN (m_chaseno, m_mouldno, m_itemcode" + ", m_rev, m_div, m_currency, m_amount, m_amounthkd, m_mpa, m_quantity, m_pcs" + ", m_itemtext, m_request, m_projecttext, m_model, m_po, m_category, m_vendor" + ", m_group, m_mouldcode, m_status, m_remarks, m_oem, m_instock50" + ", m_created, m_createdby, m_accountcode, m_costcenter, m_productbase) values" + " ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}'" + ", '{18}', '{19}', '{20}', N'{21}', '{22}', '{23}', '{24}', N'{25}', '{26}', '{27}', '{28}')", chaseno, mouldNo, partNo, rev, div, currency, amount, amountHkd, mpa, quantity, pcs, itemText, request, projectText, model, po, category, vendor, pgroup, mouldCode, status, remarks, oem, instock50, created, createdby, accountCode, costCentre, pbase); DataService.GetInstance().ExecuteNonQuery(query); } if (SavedEvent != null) { SavedEvent(this, new EventArgs()); } }
public ApiResult Post(Mould mould) { ApiResult result = new ApiResult { ReturnCode = ApiReturnCode.Error }; var userId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Sid).Value; if (mould == null) { result.Message = MessageUtil.ParamInvalid; } else { var dictItem = _context.Dictionaries.FirstOrDefault(x => x.Id == mould.TypeID); if (mould.Id == Guid.Empty) { mould.Id = Guid.NewGuid(); _context.AttachAddEntity(mould, userId); _context.Moulds.Add(mould); } else { _context.AttachUpdateEntity(mould, userId); _context.Moulds.Update(mould); } #region update img if (mould.FrontImgID.HasValue && mould.FrontImgID.Value != Guid.Empty) { byte[] content; if (_cache.TryGetValue <byte[]>(mould.FrontImgID.Value, out content)) { if (_context.SystemImages.AsNoTracking().FirstOrDefault(x => x.Id == mould.FrontImgID.Value) != null) { _context.SystemImages.Update(new SystemImage { Id = mould.FrontImgID.Value, Content = content }); } else { _context.SystemImages.Add(new SystemImage { Id = mould.FrontImgID.Value, Content = content }); } _cache.Remove(mould.FrontImgID.Value); } } else { mould.FrontImgID = null; } if (mould.SideImgID.HasValue && mould.SideImgID.Value != Guid.Empty) { byte[] content; if (_cache.TryGetValue <byte[]>(mould.SideImgID.Value, out content)) { if (_context.SystemImages.AsNoTracking().FirstOrDefault(x => x.Id == mould.SideImgID.Value) != null) { _context.SystemImages.Update(new SystemImage { Id = mould.SideImgID.Value, Content = content }); } else { _context.SystemImages.Add(new SystemImage { Id = mould.SideImgID.Value, Content = content }); } //_cache.Remove(mould.FrontImgID.Value); } } else { mould.SideImgID = null; } if (mould.BackImgID.HasValue && mould.BackImgID.Value != Guid.Empty) { byte[] content; if (_cache.TryGetValue <byte[]>(mould.BackImgID.Value, out content)) { if (_context.SystemImages.AsNoTracking().FirstOrDefault(x => x.Id == mould.BackImgID.Value) != null) { _context.SystemImages.Update(new SystemImage { Id = mould.BackImgID.Value, Content = content }); } else { _context.SystemImages.Add(new SystemImage { Id = mould.BackImgID.Value, Content = content }); } _cache.Remove(mould.FrontImgID.Value); } } else { mould.BackImgID = null; } #endregion if (_context.SaveChanges() > 0) { var mouldItem = mould; result.Data = new { mouldItem.Id, mouldItem.Creator, mouldItem.BackImgID, mouldItem.FrontImgID, mouldItem.Height, mouldItem.RelateMaterial, mouldItem.SerialNum, mouldItem.SideImgID, mouldItem.Size, mouldItem.Spec, mouldItem.TypeID, mouldItem.Width, TypeName = dictItem == null ? "--" : dictItem.TypeName }; result.ReturnCode = ApiReturnCode.Succeed; } else { result.Message = "更新失败"; } } return(result); }
public static void ExportPdf(DataTable table) { Document doc = new Document(PageSize.A4.Rotate(), 50, 50, 50, 50); string tm = DateTime.Today.ToString("yy/MM"); int id = 0; string query = string.Format("select top 1 d_seqid from TB_FA_RECORD where d_month = '{0}' order by d_id desc", tm); using (GlobalService.Reader = DataService.GetInstance().ExecuteReader(query)) { if (!GlobalService.Reader.HasRows) { id = 0; } else { while (GlobalService.Reader.Read()) { id = GlobalService.Reader.GetInt32(0); } } } string year = string.Format("{0:yy}", DateTime.Today); string month = string.Format("{0:MM}", DateTime.Today); id += 1; string strId = id.ToString("D3"); string filename = "FA" + year + month + "_" + strId + ".pdf"; string storedPath = @"\\kdthk-dm1\MOSS$\CM\FixedAssets\test\" + filename; string insertText = string.Format("insert into TB_FA_RECORD (d_filename, d_datetime, d_month, d_seqid)" + " values ('{0}', '{1}', '{2}', '{3}')", filename, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), tm, id); DataService.GetInstance().ExecuteNonQuery(insertText); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(storedPath, FileMode.Create)); doc.Open(); System.Drawing.Bitmap bmp = System.Drawing.Image.FromHbitmap(Properties.Resources.img_kyocera.GetHbitmap()); var converter = new System.Drawing.ImageConverter(); Image img = Image.GetInstance((byte[])converter.ConvertTo(bmp, typeof(byte[]))); img.SetAbsolutePosition(0, doc.PageSize.Height - img.Height); doc.Add(img); PdfPTable ptb = null; Font headerFont = FontFactory.GetFont("Calibri", 13); Font cellFont = FontFactory.GetFont("Calibri", 10); string title = filename.Substring(0, filename.LastIndexOf(".")); PdfPCell hTitle = new PdfPCell(new Phrase("Mgt No : " + title + "\nDownload Datetime : " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), headerFont)); PdfPCell hChaseNo = new PdfPCell(new Phrase("Chase No.", headerFont)); PdfPCell hItemText = new PdfPCell(new Phrase("Item Text", headerFont)); PdfPCell hPartNo = new PdfPCell(new Phrase("Part No.", headerFont)); PdfPCell hRingi = new PdfPCell(new Phrase("Ringi", headerFont)); PdfPCell hVendor = new PdfPCell(new Phrase("Vendor", headerFont)); ptb = new PdfPTable(5); ptb.SpacingBefore = 0; float width = PageSize.A4.Rotate().Width / 5; float[] headerWidths = { width - 50, width + 50, width - 50, width - 50, width + 100 }; ptb.SetWidths(headerWidths); ptb.WidthPercentage = 100; hTitle.HorizontalAlignment = Element.ALIGN_LEFT; hTitle.Colspan = 5; hTitle.Border = iTextSharp.text.Rectangle.NO_BORDER; ptb.DefaultCell.BorderWidth = 2; ptb.DefaultCell.HorizontalAlignment = 1; hChaseNo.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hItemText.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hPartNo.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hRingi.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); hVendor.BackgroundColor = new BaseColor(System.Drawing.Color.WhiteSmoke); ptb.AddCell(hTitle); ptb.AddCell(hChaseNo); ptb.AddCell(hItemText); ptb.AddCell(hPartNo); ptb.AddCell(hRingi); ptb.AddCell(hVendor); foreach (DataRow row in table.Rows) { string chaseNo = row.ItemArray[0].ToString(); string itemText = row.ItemArray[1].ToString(); PdfPCell cChaseNo = new PdfPCell(new Phrase(chaseNo, cellFont)); PdfPCell cItemText = new PdfPCell(new Phrase(itemText, cellFont)); PdfPCell cPartNo = new PdfPCell(new Phrase(row.ItemArray[2].ToString(), cellFont)); PdfPCell cRingi = new PdfPCell(new Phrase(row.ItemArray[3].ToString(), cellFont)); PdfPCell cVendor = new PdfPCell(new Phrase(row.ItemArray[4].ToString(), cellFont)); ptb.AddCell(cChaseNo); ptb.AddCell(cItemText); ptb.AddCell(cPartNo); ptb.AddCell(cRingi); ptb.AddCell(cVendor); string updateText = string.Format("update TB_MOULD_MAIN set mm_pdfid = '{0}', mm_status_code = 'A' where mm_chaseno = '{1}'", title, chaseNo); DataService.GetInstance().ExecuteNonQuery(updateText); string mpa = Mould.GetMpa(chaseNo); string vendor = Mould.GetVendor(chaseNo); //string faText = string.Format("insert into TB_FA_APPROVAL (f_chaseno, f_pdfid, f_status, f_desc, f_mpa, f_vendor)" + // " values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", chaseNo, title, "IPO 1st Approval", cItemText, mpa, vendor); string faText = string.Format("insert into TB_FA_APPROVAL (f_applicant, f_type, f_chaseno, f_pdfid, f_status, f_desc, f_mpa" + ", f_vendor, f_mould) values (N'{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}')", GlobalService.Owner, "Acquisition", chaseNo, title, itemText, DataUtil.GetMpa(chaseNo), DataUtil.GetVendor(chaseNo), DataUtil.GetMouldNo(chaseNo)); DataService.GetInstance().ExecuteNonQuery(faText); } doc.Add(ptb); doc.Close(); }
private void tsbtnSave_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dgvPreview.Rows) { string mouldNo = row.Cells[1].Value.ToString(); string partNo = row.Cells[2].Value.ToString(); string rev = row.Cells[3].Value.ToString(); string fromVendor = row.Cells[4].Value.ToString(); string toVendor = row.Cells[5].Value.ToString(); string remarks = row.Cells[8].Value.ToString(); string pcs = row.Cells[9].Value.ToString(); string chaseNo = row.Cells[10].Value.ToString(); List <string> list = FaList(chaseNo); string fa = ""; string category = "K"; if (list.Count == 0) { fa = ""; } else if (list.Count == 1) { fa = list[0].ToString(); category = "A"; } else { fa = string.Join(",", list.ToArray()); category = "A"; } string lastChaseNo = Mould.GetLatestChaseNo(); string tmNo = lastChaseNo.Replace("MS", "TM"); string purG = Vendor.GetVendorGroup(toVendor); string div = Mould.GetDiv(chaseNo); string mouldCode = Mould.GetMouldCode(chaseNo); string itemText = mouldNo + "MP+" + Mould.GetMouldCode(chaseNo) + "+TM"; string type = "TM"; string isModify = "False"; string projectText = partNo + "-" + rev; string request = partNo + rev; string quantity = "1"; string amount = "0"; string currency = Vendor.GetVendorCurrency(toVendor); string status = "T"; string owner = "KDTHK"; string common = "Non-Common"; string model = mouldNo.Substring(1, 3); string query = string.Format("insert into TB_MOULD_MAIN (mm_chaseno, mm_mouldno, mm_itemcode, mm_rev" + ", mm_div, mm_type, mm_currency, mm_amount, mm_amounthkd, mm_mpa, mm_mouldcode, mm_vendorcode" + ", mm_status_code, mm_quantity, mm_itemtext, mm_projecttext, mm_request, mm_owner, mm_category" + ", mm_created, mm_createdby, mm_model, mm_group, mm_po, mm_fixedassetcode" + ", mm_pcs, mm_ismodify, mm_remarks) values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}'" + ", '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}', '{20}', '{21}', '{22}', '{23}', '{24}', '{25}', '{26}', '{27}')", lastChaseNo, mouldNo, partNo, rev, div, type, currency, amount, amount, "False", mouldCode, toVendor, status, quantity, itemText, projectText, request, owner, category, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), GlobalService.Owner, model, purG, tmNo, fa, pcs, isModify, remarks); DataService.GetInstance().ExecuteNonQuery(query); this.SaveTransferHistory(tmNo, mouldNo, partNo, rev, fromVendor, toVendor, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), chaseNo, fa, remarks); } MessageBox.Show("Record has been saved."); dgvPreview.Rows.Clear(); }