/// <summary> /// 同步供应商基础数据 /// </summary> /// <param name="sapSupplierQuotaInfos"></param> /// <param name="loginUser"></param> private static string GetSyncSupplierSql(List <SapSupplierQuotaInfo> sapSupplierQuotaInfos, string loginUser) { StringBuilder @string = new StringBuilder(); ///获取业务表中要变更的数据集合,准备对比 List <SupplierInfo> supplierInfos = new SupplierBLL().GetListForInterfaceDataSync(sapSupplierQuotaInfos.Select(d => d.Lifnr).ToList()); /// foreach (var sapSupplierQuotaInfo in sapSupplierQuotaInfos) { SupplierInfo supplierInfo = supplierInfos.FirstOrDefault(d => d.SupplierNum == sapSupplierQuotaInfo.Lifnr); if (supplierInfo == null) { supplierInfo = new SupplierInfo(); supplierInfo.Fid = Guid.NewGuid(); supplierInfo.SupplierNum = sapSupplierQuotaInfo.Lifnr; supplierInfo.SupplierName = sapSupplierQuotaInfo.SupplierName; supplierInfo.SupplierType = (int)SupplierTypeConstants.MaterialSupplier; supplierInfo.CreateUser = loginUser; supplierInfo.CreateDate = DateTime.Now; @string.AppendLine(SupplierDAL.GetInsertSql(supplierInfo)); supplierInfos.Add(supplierInfo); continue; } ///更新 @string.AppendLine("update [LES].[TM_BAS_SUPPLIER] " + "set [SUPPLIER_NAME] = N'" + sapSupplierQuotaInfo.SupplierName + "'," + "[MODIFY_USER] = N'" + loginUser + "'," + "[MODIFY_DATE] = GETDATE() " + "where [FID] = N'" + supplierInfo.Fid.GetValueOrDefault() + "';"); } return(@string.ToString()); }
private void splBtnSave_Click(object sender, EventArgs e) { if (txtEdtName.Text != "" && txtEdtPhoneNumber.Text != "" && txtAddress.Text != "") { if (txtEdtID.Text == "") { try { GetData(); dgvSupplier.DataSource = supplierBLL.Add(supplier); ClearData(); GetAll(); XtraMessageBox.Show("Đã thêm thông tin nhà cung cấp " + supplier.Name, "THÔNG BÁO!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { XtraMessageBox.Show("Tên nhà cung cấp đã tồn tại", "THÔNG BÁO!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { int rowIndex = dgvSupplier.CurrentRow.Index; supplier.Name = dgvSupplier["Tên nhà cung cấp", rowIndex].Value.ToString(); supplier.PhoneNumber = dgvSupplier["Số điện thoại", rowIndex].Value.ToString(); supplier.Address = dgvSupplier["Địa chỉ", rowIndex].Value.ToString(); if (supplier.Name != txtEdtName.Text || supplier.PhoneNumber != txtEdtPhoneNumber.Text || supplier.Address != txtAddress.Text) { try { GetData(); dgvSupplier.DataSource = supplierBLL.Update(supplier); ClearData(); GetAll(); XtraMessageBox.Show("Đã sửa thông tin nhà cung cấp " + supplier.Name, "THÔNG BÁO!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { XtraMessageBox.Show("Tên nhà cung cấp đã tồn tại", "THÔNG BÁO!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } else { XtraMessageBox.Show("Vui lòng nhập đủ các thông tin", "THÔNG BÁO!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void button1_Click(object sender, EventArgs e) { try { emp.SupplierID = int.Parse(textBox1.Text); emp.CompanyName = textBox2.Text; emp.Address = textBox3.Text; emp.ContactPerson = textBox4.Text; emp.ContactNo = textBox5.Text; emp.Validate(); emp.Add(); MessageBox.Show("Add Record Successful!"); ResetControls(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source); } }