private void tsbtsave_Click(object sender, EventArgs e) { string pid = "NULL"; int gr = 1; if (cbloai.Text != "") { pid = gen.GetString("select InventoryCategoryID from InventoryItemCategory where InventoryCategoryCode='" + cbloai.SelectedValue.ToString() + "'"); string t = gen.GetString("select Grade from InventoryItemCategory where InventoryCategoryCode='" + cbloai.SelectedValue.ToString() + "'"); gr = int.Parse(t) + 1; } if (active == "1") { string sql; if (pid == "NULL") { sql = "update InventoryItemCategory set InventoryCategoryName=N'" + txtname.Text + "',Inactive='" + checkBox1.Checked.ToString() + "',Grade='" + gr + "' where InventoryCategoryID='" + role + "'"; } else { sql = "update InventoryItemCategory set InventoryCategoryName=N'" + txtname.Text + "',Inactive='" + checkBox1.Checked.ToString() + "',ParentID='" + pid + "',Grade='" + gr + "' where InventoryCategoryID='" + role + "'"; gen.ExcuteNonquery("update InventoryItemCategory set IsParent='True' where InventoryCategoryID='" + pid + "'"); } // iic.checkiic(active, txtcode, txtname, sql, this, pid, role); } else { string sql = "insert into InventoryItemCategory(InventoryCategoryID,InventoryCategoryCode,InventoryCategoryName,Inactive,ParentID,Grade) values(newid(),'" + txtcode.Text + "',N'" + txtname.Text + "','" + checkBox1.Checked.ToString() + "','" + pid + "','" + gr + "')"; if (pid != "NULL") { gen.ExcuteNonquery("update InventoryItemCategory set IsParent='True' where InventoryCategoryID='" + pid + "'"); } // iic.checkiic(active, txtcode, txtname, sql, this, pid, role); } }
private void tsbtcat_Click(object sender, EventArgs e) { ledt.Focus(); if (active == "1" && thue != txttthue.Text) { DialogResult dr = XtraMessageBox.Show("Thuế được thay từ < " + thue + " đồng > sang < " + txttthue.Text + " đồng >, bạn có muốn tiếp tục?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); if (dr == DialogResult.Cancel) { return; } } pxk.checkhdmh(active, role, this, gridView1, ledt, cbldt, txtsct, txtname, txtdc, txtldn, denct, denht, tsbtboghi, tsbtghiso, tsbtxoa, tsbtcat, tsbtin, tsbtsua, tsbtnap, ngaychungtu, cbthue, txtshd, txtkhhd, txtnhd, txthtt, txthttt, txtms, le1562, branchid, userid, txttthue, ledv, tsbttruoc, tsbtsau, txtmst, txtctg, txtptvc, txtspx, cbtkdu, txtddh, chhnk, txtck, txttaixe, txtgn); refreshrole(); click = "true"; change(); click = "false"; if (active == "1") { gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Sửa','" + txtsct.Text + "')"); thue = txttthue.Text; } else { gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Thêm','" + txtsct.Text + "')"); } }
private void tsbtcat_Click(object sender, EventArgs e) { ledt.Focus(); if (pt == "pnk") { pnk.checkpnk(active, role, this, gridView1, ledt, ledv, cbldt, txtsct, txtname, txtdc, txtngh, txtctg, txtldn, denct, denht, tsbtboghi, tsbtghiso, tsbtxoa, tsbtcat, tsbtin, tsbtsua, tsbtnap, ngaychungtu, txtmst, txtptvc, userid, branchid, tsbttruoc, tsbtsau, chtc); } else if (pt == "pnkvtddh") { pnktddh.checkpnk(active, role, this, gridView1, ledt, ledv, cbldt, txtsct, txtname, txtdc, txtngh, txtctg, txtldn, denct, denht, tsbtboghi, tsbtghiso, tsbtxoa, tsbtcat, tsbtin, tsbtsua, tsbtnap, ngaychungtu, txtmst, txtptvc, userid, branchid, tsbttruoc, tsbtsau, chtc, txttaixe); } else { pxk.checkpxk(active, role, this, gridView1, ledt, ledv, cbldt, txtsct, txtname, txtdc, txtngh, txtctg, txtldn, denct, denht, tsbtboghi, tsbtghiso, tsbtxoa, tsbtcat, tsbtin, tsbtsua, tsbtnap, ngaychungtu, txtmst, txtptvc, userid, branchid, tsbttruoc, tsbtsau, chtc, txttaixe); } refreshrole(); click = "true"; change(); click = "false"; if (active == "1") { gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Sửa','" + txtsct.Text + "')"); } else { gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Thêm','" + txtsct.Text + "')"); } }
public void gettieude(string nhanvien, string ngaychungtu) { xrLabel1.Text = gen.GetString("select Top 1 CompanyName from Center"); xrLabel2.Text = "NHẬT KÝ BÁN HÀNG NGÀY " + String.Format("{0:dd/MM/yyyy}", DateTime.Parse(ngaychungtu)); xrLabel5.Text = gen.GetString("select AccountingObjectCode+' - '+AccountingObjectName from AccountingObject where AccountingObjectID='" + nhanvien + "'").ToUpper(); xrLabel4.Text = "In lúc: " + String.Format("{0:HH:mm:ss}", DateTime.Now) + " ngày: " + String.Format("{0:dd-MM-yyyy}", DateTime.Now); }
private void tsbtboghi_Click(object sender, EventArgs e) { tsbtghiso.Visible = true; tsbtboghi.Visible = false; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i][3].ToString() == "EDIT") { tsbtsua.Enabled = true; } } if (pt == "pttmvt") { gen.ExcuteNonquery("update SUCAReceipt set Posted='False' where RefID='" + role + "'"); } else if (pt == "ptnhvt") { gen.ExcuteNonquery("update SUBADeposit set Posted='False' where RefID='" + role + "'"); } else if (pt == "pctmvt") { gen.ExcuteNonquery("update SUCAPayment set Posted='False' where RefID='" + role + "'"); } else if (pt == "pcnhvt") { gen.ExcuteNonquery("update SUBATransfer set Posted='False' where RefID='" + role + "'"); } gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Bỏ ghi','" + txtsct.Text + "')"); }
private void btlogin_Click(object sender, EventArgs e) { if (txtten.Text == "Tên đăng nhập" || txtten.Text == "") { XtraMessageBox.Show("Bạn chưa nhập tên đăng nhập.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtten.Focus(); } else if (txtmk.Text == "Mật khẩu" || txtmk.Text == "") { XtraMessageBox.Show("Bạn chưa nhập mật khẩu.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtmk.Focus(); } else { try { // gencon gen = new gencon(); //trong luc cho xu lý thì load frm_wait lên SplashScreenManager.ShowForm(typeof(Frm_wait)); string userid = ""; try { userid = gen.GetString("select Userid from Users where UserName='******' and Password='******' AND " + " ClientID =" + txtClient.Text); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Error); } SplashScreenManager.CloseForm(); //int clientid = Int16.Parse(txtClientID.Text); Globals.userid = userid; Globals.clientid = Int32.Parse(txtClient.Text); Globals.username = txtten.Text.Replace("-", ""); Globals.companycode = gen.GetString2("Users", "companycode", "Username", Globals.username, Globals.clientid); Globals.ngaychungtu = DateTime.Now.ToString(); //DataTable dtinfo = gen.GetTable("select FullName,BranchName,a.BranchID from MSC_User a with (NOLOCK), Branch b with (NOLOCK) where UserID='" + userid + "' and a.BranchID=b.BranchID "); //Globals.branchid = dtinfo.Rows[0][2].ToString(); //Globals.khach = gen.GetTable("select AccountingObjectID as 'ID',AccountingObjectCode as 'Mã khách hàng',AccountingObjectName as 'Tên khách',Address as 'Địa chỉ', CompanyTaxCode as 'Mã số thuế', ContactHomeTel as 'Đội' from AccountingObject with (NOLOCK) order by AccountingObjectCode"); //Globals.hang = gen.GetTable("select InventoryItemID as 'ID',InventoryItemCode as 'Mã hàng hóa',InventoryItemName as 'Tên hàng',Unit as 'Đơn vị tính', ConvertUnit as 'Đơn vị quy đổi',convert(decimal(22,2),ConvertRate) as 'Tỷ lệ quy đổi',SalePrice as 'Đơn giá tham khảo',GuarantyPeriod as 'Công ty' from InventoryItem with (NOLOCK) order by InventoryItemCode"); //Globals.roleid = gen.GetString("select RoleID from MSC_UserJoinRole with (NOLOCK) where UserID='" + userid + "'"); //Form1 F = new Form1();// mo Form 1 báo cáo ghi nợ MainForm F = new MainForm(); //F.getform(this); //-- cua Form1 //F.getuserid(userid); //-- cua Form1 F.Show(); } catch { XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtmk.Text = ""; txtmk.Focus(); SplashScreenManager.CloseForm(); } } }
private void Frm_user_Load(object sender, EventArgs e) { txtSQL.Visible = false; txtCompanyCode.ReadOnly = true; txtInactive.ReadOnly = true; //branch load_ledv(); //kho load_txtStockCode(); load_txtStockCode2(); // role load_txtRole(); if (active == "1") { this.Text = "Sửa người dùng"; var ctx = gen.GetNewEntity(); // khai bao new entity Framework var query = ctx.MSC_User .Where(c => c.UserName == username && c.CompanyCode == Globals.companycode); //da = gen.GetTable("select * from MSC_User where UserID = '" + role + "'"); foreach (var data in query) { txtuser.Text = data.UserName; txtname.Text = data.FullName; txtjob.Text = data.JobTitle; txtdes.Text = data.Description; txtInactive.Text = data.Inactive.ToString(); txtCompanyCode.Text = data.CompanyCode; txtmail.Text = data.Email; txtweb.Text = data.Website; txtwphone.Text = data.WorkPhone; txtphone.Text = data.MobilePhone; txthphone.Text = data.HomePhone; txtfax.Text = data.Fax; txtwadress.Text = data.WorkAddress; txthadress.Text = data.HomeAddress; string dv = gen.GetString("select BranchCode from Branch where BranchID='" + data.BranchID.ToString() + "'"); ledv.EditValue = dv; role = data.UserID.ToString(); // doi dang GUID --> string password = data.Password; } load_lai_grid_kho(); load_lai_grid_kho2(); load_lai_grid_role(); } else { this.Text = "Thêm người dùng"; txtCompanyCode.Text = Globals.companycode; txtInactive.Text = "False"; txtuser.Text = username; txtuser.ReadOnly = true; } }
private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e) { gridView1.UpdateCurrentRow(); if (e.Column.FieldName == "Mã hàng") { DataTable da = new DataTable(); da = gen.GetTable("select * from InventoryItem where Parent in (select InventoryItemID from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Mã hàng").ToString() + "')"); if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Tên hàng").ToString() == "") { string tenhang = gen.GetString("select InventoryItemName from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Mã hàng").ToString() + "'"); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Tên hàng"], tenhang); gridView2.AddNewRow(); gridView2.SetRowCellValue(gridView2.FocusedRowHandle, gridView2.Columns["Mã hàng"], da.Rows[0][2].ToString()); gridView2.SetRowCellValue(gridView2.FocusedRowHandle, gridView2.Columns["Tên hàng"], da.Rows[0][4].ToString()); } else { string tenhang = gen.GetString("select InventoryItemName from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Mã hàng").ToString() + "'"); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Tên hàng"], tenhang); gridView2.SetRowCellValue(gridView1.FocusedRowHandle, gridView2.Columns["Mã hàng"], da.Rows[0][2].ToString()); gridView2.SetRowCellValue(gridView1.FocusedRowHandle, gridView2.Columns["Tên hàng"], da.Rows[0][4].ToString()); } gridView2.UpdateCurrentRow(); } else if (e.Column.FieldName == "Số lượng") { gridView2.SetRowCellValue(gridView1.FocusedRowHandle, gridView2.Columns["Số lượng"], gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Số lượng").ToString()); gridView2.UpdateCurrentRow(); } else if (e.Column.FieldName == "Số lượng quy đổi" || e.Column.FieldName == "Đơn giá") { if (caseup == "1") { if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Số lượng quy đổi").ToString() != "" && gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Đơn giá").ToString() != "") { Double a = Double.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Số lượng quy đổi").ToString()); Double b = Double.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Đơn giá").ToString()); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Thành tiền"], (a * b).ToString()); } } } else if (e.Column.FieldName == "Thành tiền" || e.Column.FieldName == "Chi phí") { Double thanhtien = Double.Parse(gridView1.Columns["Thành tiền"].SummaryText); Double chiphi = Double.Parse(gridView1.Columns["Chi phí"].SummaryText); txtcth.Text = String.Format("{0:n0}", thanhtien + chiphi); if (caseup == "2") { if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Số lượng quy đổi").ToString() != "" && gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Thành tiền").ToString() != "") { Double a = Double.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Số lượng quy đổi").ToString()); Double b = Double.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Thành tiền").ToString()); gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Đơn giá"], (b / a).ToString()); } } } }
private void basave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { txtname.Focus(); if (rbcpn.Checked == true) { check = "1"; } else if (rbltu.Checked == true) { check = "2"; } else if (rbtnn.Checked == true) { check = "3"; } else if (rbgvn.Checked == true) { check = "4"; } else { check = "0"; } if (active == "1") { gen.ExcuteNonquery("delete Descasc where DescascCode=(select DescascCode from Descasc where DescascID='" + role + "')"); } Double so = 0; try { so = Double.Parse(gen.GetString("select Max(DescascCode) from Descasc")) + 1; } catch { } for (int i = 0; i < gridView1.RowCount - 1; i++) { string makho = gridView1.GetRowCellValue(i, "Mã kho").ToString(); makho = gen.GetString("select StockID from Stock where StockCode='" + makho + "'"); string sotien = gridView1.GetRowCellValue(i, "Số tiền").ToString().Replace(".", ""); string diengiai = gridView1.GetRowCellValue(i, "Diễn giải").ToString(); string manganh = gridView1.GetRowCellValue(i, "Mã ngành").ToString(); gen.ExcuteNonquery("insert into Descasc values(newid(),'" + so + "',N'" + txtname.EditValue + "','" + ledv.EditValue + "','" + makho + "','" + sotien + "',N'" + diengiai + "','" + check + "','" + txtdvsd.EditValue + "','" + manganh + "')"); } XtraMessageBox.Show("Dữ liệu của bạn đã được lưu.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.None); this.myac(); this.Close(); }
private void baadd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { txtshd.Focus(); if (txtshd.Text == "") { XtraMessageBox.Show("Bạn chưa nhập Số phụ lục - bảo lãnh.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (lehd.EditValue == null) { XtraMessageBox.Show("Bạn chưa chọn Hợp đồng.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (denk.EditValue == null) { XtraMessageBox.Show("Bạn chưa nhập Ngày ký.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (active == "0") { try { gen.GetString("select * from ContractB where ContractCode=N'" + txtshd.EditValue + "'"); XtraMessageBox.Show("Phụ lục - Bảo lãnh này đã có trong hệ thống.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } catch { } } hd.checkplbl(active, role, lehd, txtshd, ledv, sekh, txtsdt, txtfax, txtndd, txtcv, txtguq, txtnc, txtndtd, denk, denhh, txthmn, txthn, rbpl, rbbl, txtddgh, denl, deng, denqv, txtnl, txttenbl, chenqv, txthmtd); XtraMessageBox.Show("Dữ liệu đã được cập nhật.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Information); myac(); this.Close(); }
public string getrolecode(string a) { SQLString = "select [rolecode] from [Roles] where roleid='" + a + "' AND ClientID=" + clientid; String rolecode = ""; try { rolecode = gen.GetString(SQLString); } catch { rolecode = ""; //txtSQL.Text = SQLString; } return(rolecode); }
public void checkdistrist(string ac, TextBox a, TextBox b, string sql, Frm_distrist F) { if (a.Text == "") { MessageBox.Show("Mã quận/huyện không được bỏ trống.", "HAMACO"); } else if (b.Text == "") { MessageBox.Show("Tên quận/huyện không được bỏ trống.", "HAMACO"); } else { if (ac == "1") { gen.ExcuteNonquery(sql); F.myac(); F.Close(); } else { try { string kq = gen.GetString("select * from Distrist where DistristCode='" + a.Text + "'"); MessageBox.Show("Mã quận/huyện này đã tồn tại.", "HAMACO"); } catch { gen.ExcuteNonquery(sql); F.myac(); F.Close(); } } } }
private void load_menuFav() { //SQLString = "select * from TransactionFav where ClientID=" + clientid + " AND username ='******'"; SQLString = "select a.TransactionCode,a.UserName, b.TransactionName, b.FormName from TransactionFav a, Transactions b " + "where a.TransactionCode = b.TransactionCode "; SQLString += " AND a.username ='******'"; try { dt = gen.GetTable(SQLString); } catch { // MessageBox.Show(SQLString); } DataTable temp2 = new DataTable(); navBarControl1.BeginUpdate(); navBarGroup1.ItemLinks.Clear(); navBarControl1.Groups.Add(navBarGroup1); for (int i = 0; i < dt.Rows.Count; i++) { string tcode = dt.Rows[i][0].ToString().Trim(); //txtSQL.Text = tcode; string tname = gen.GetString("select TransactionName from transactions where transactioncode='" + tcode + "'"); NavBarItem itemInbox = new NavBarItem(tcode.ToUpper() + " - " + tname); navBarGroup1.ItemLinks.Add(itemInbox); //lblSQL.Text = tcode; } navBarGroup1.Expanded = true; navBarControl1.EndUpdate(); navBarControl1.LinkClicked += new NavBarLinkEventHandler(navBarControl1_LinkClicked); }
private void Depreciation_Load(object sender, EventArgs e) { loadstock(); if (active == "1") { DataTable da = gen.GetTable("select * from Depreciation where DepreciationID='" + role + "'"); txtname.EditValue = da.Rows[0][2].ToString(); if (da.Rows[0][3].ToString() != "") { txtdvsd.EditValue = DateTime.Parse(da.Rows[0][3].ToString()); } if (da.Rows[0][4].ToString() != "") { txttgkh.EditValue = da.Rows[0][4]; } if (da.Rows[0][5].ToString() != "") { txttghkh.EditValue = DateTime.Parse(da.Rows[0][5].ToString()); } if (da.Rows[0][6].ToString() != "") { txtng.EditValue = da.Rows[0][6]; } if (da.Rows[0][8].ToString() != "") { txttontruoc.EditValue = Double.Parse(da.Rows[0][8].ToString()); } if (da.Rows[0][7].ToString() != "") { txtkhbq.EditValue = da.Rows[0][7]; } if (da.Rows[0][8].ToString() != "") { txtgtcl.EditValue = da.Rows[0][8]; } if (da.Rows[0][9].ToString() != "") { txttgcl.EditValue = da.Rows[0][9]; } if (da.Rows[0][10].ToString() != "") { txtts.EditValue = da.Rows[0][10]; } if (da.Rows[0][11].ToString() != "") { txtlv.EditValue = da.Rows[0][11]; } if (da.Rows[0][14].ToString() == "1") { chkhcd.Checked = true; } ledv.EditValue = gen.GetString("select StockCode from Stock where StockID='" + da.Rows[0][12].ToString() + "'"); } }
private void Frm_iistock_Load(object sender, EventArgs e) { DataTable temp = new DataTable(); DataTable da = new DataTable(); if (tsbt == "") { temp.Columns.Add("Mã kho"); temp.Columns.Add("Tên kho"); da = gen.GetTable("select a.StocKID,StockCode,StockName from Stock a, MSC_UserJoinStock b where a.StockID=b.StockID and UserID='" + userid + "' order by StockCode "); for (int i = 0; i < da.Rows.Count; i++) { DataRow dr = temp.NewRow(); dr[0] = da.Rows[i][1].ToString(); dr[1] = da.Rows[i][2].ToString(); temp.Rows.Add(dr); } ledv.Properties.DataSource = temp; ledv.Properties.DisplayMember = "Mã kho"; ledv.Properties.ValueMember = "Mã kho"; ledv.ItemIndex = 0; ledv.Properties.PopupWidth = 300; this.barnct.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; } else if (tsbt == "barbgdh") { labelControl7.Visible = false; ledv.Visible = false; this.barButtonItem44.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; getnct(); if (gen.GetString("select IsBranchManager from MSC_User where UserID='" + userid + "'") == "True") { this.bartaitaptin.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; this.batai.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; } } else if (tsbt == "barbglpg") { labelControl7.Visible = false; ledv.Visible = false; this.barButtonItem44.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; getnctbglpg(); this.bartaitaptin.Caption = "Cập nhật "; if (gen.GetString("select IsBranchManager from MSC_User where UserID='" + userid + "'") == "True") { this.batai.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; this.batai.Caption = "Duyệt giá "; } } }
private void load_datagrid() { lvpq.Visible = true; SQLString = "SELECT count(*) FROM information_schema.tables"; lblSum.Text = gen.GetString(SQLString); lblSum.Text = "There are " + lblSum.Text + " tables and views in the database."; SQLString = "SELECT * FROM information_schema.tables"; try { dt = gen.GetTable(SQLString); } catch { XtraMessageBox.Show(SQLString, "load_datagrid", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSQL.Visible = true; txtSQL.Text = SQLString; } DataTable temp = new DataTable(); temp.Columns.Add("No"); temp.Columns.Add("Table Name"); temp.Columns.Add("Type"); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = temp.NewRow(); dr[0] = i + 1; dr[1] = dt.Rows[i][2].ToString(); dr[2] = dt.Rows[i][3].ToString(); temp.Rows.Add(dr); } lvpq.DataSource = temp; }
private void Frm_changepass_Load(object sender, EventArgs e) { txtten.Text = gen.GetString("select UserName from MSC_User where UserID='" + userid + "'"); }
private void tsbtsave_Click(object sender, EventArgs e) { string code = txtma.Text; string name = txtname.Text.Replace("'", "''"); string branch = cbbranch.SelectedValue.ToString(); //string branchID = gen.GetString("select BranchID from Branch where BranchCode='" + branch + "'"); string dc = txtdc.Text.Replace("'", "''"); string mst = txtmst.Text; string email = txtemail.Text; if (txtemail.Text != "") { try { gen.GetString("select * from AccountingObject where AccountingObjectCode='" + txtemail.Text + "'"); } catch { XtraMessageBox.Show("Mã khách phụ không tồn tại vui lòng kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } string tknh = txttknh.Text; string tnh = txtnh.Text; string chucdanh = txtcv.Text; string cmnd = txtcmnd.Text; DateTime ngaycap = dtngaycap.Value; DateTime ngaysinh = dtborn.Value; string noicap = txtnoicap.Text; string dtcq = txtdtcq.Text; string dtnr = txtdtnr.Text; string dtdd = txtdtdd.Text; string kh = chbkh.Checked.ToString(); string ncc = chncc.Checked.ToString(); string person = "True"; string ntd = chbntd.Checked.ToString(); string sex; string hsl = txthsl.Text; if (txthsl.Text == "") { hsl = "0"; } string gtgc = txtgtgc.Text.Replace(",", "."); if (rbfemale.Checked == true) { sex = "0"; } else { sex = "1"; } /*if (active == "1") * { * string sql = "update AccountingObject set AccountingObjectName=N'" + name + "',BranchID='" + branchID + "',ContactSex='" + sex + "', * EmployeeBirthday='" + ngaysinh + "',Address=N'" + dc + "',EmailAddress='" + email + "',BankAccount='" + tknh + "',BankName='" + tnh + "', * CompanyTaxCode='" + mst + "',ContactTitle=N'" + chucdanh + "',ContactMobile='" + dtdd + "',ContactOfficeTel='" + dtcq + "', * ContactHomeTel='" + dtnr + "',IsPersonal='" + person + "',IdentificationNumber='" + cmnd + "',IssueDate='" + ngaycap + "', * IssueBy='" + noicap + "',Inactive='" + ntd + "',IsVendor='" + ncc + "',IsCustomer='" + kh + "',FamilyDeductionAmount='" + gtgc + "',SalaryScaleID='" + hsl + "' where AccountingObjectID='" + role + "'"; * nhanvien.checknhanvien(active, txtma, txtname, sql, this); * } * else * { * string nv = "True"; * string insu = "False"; * string labe = "False"; * //string sql = "insert into AccountingObject(AccountingObjectID,AccountingObjectCode,AccountingObjectName,BranchID,Address,EmailAddress,BankAccount,BankName,CompanyTaxCode,ContactTitle,ContactMobile,ContactOfficeTel,ContactHomeTel,IsPersonal,IdentificationNumber,IssueDate,IssueBy,Inactive,IsVendor,IsCustomer,IsEmployee,Insured,LabourUnionFee,FamilyDeductionAmount,AccountingObjectCategory,ContactSex,EmployeeBirthday,SalaryScaleID) values(newid(),'" + code + "',N'" + name + "','" + branchID + "',N'" + dc + "','" + email + "','" + tknh + "','" + tnh + "','" + mst + "',N'" + chucdanh + "','" + dtdd + "','" + dtcq + "','" + dtnr + "','" + person + "','" + cmnd + "','" + ngaycap + "','" + noicap + "','" + ntd + "','" + ncc + "','" + kh + "','" + nv + "','" + insu + "','" + labe + "','" + gtgc + "','','" + sex + "','" + ngaysinh + "','" + hsl + "')"; * //nhanvien.checknhanvien(active, txtma, txtname, sql, this); * }*/ AccountingObject data = new AccountingObject(); if (active == "0") { data.AccountingObjectID = Guid.NewGuid();// tao guiid moi } else { data.AccountingObjectID = Guid.Parse(role);; } //data.ClientID = Globals.clientid; data.CompanyCode = Globals.companycode; data.AccountingObjectCode = code; data.AccountingObjectName = name; data.BranchID = Guid.Parse(branch); data.ContactSex = Int32.Parse(sex); data.EmployeeBirthday = ngaysinh; data.Address = dc; data.EmailAddress = email; data.BankAccount = tknh; data.BankName = tnh; data.CompanyTaxCode = mst; data.ContactTitle = chucdanh; data.ContactMobile = dtdd; data.ContactOfficeTel = dtcq; data.ContactHomeTel = dtnr; data.IsPersonal = true; data.IsEmployee = true; data.IdentificationNumber = cmnd; data.IssueDate = ngaycap; data.ContactTitle = chucdanh; data.IssueBy = noicap; data.Inactive = chbntd.Checked; data.IsVendor = chncc.Checked; data.IsCustomer = chbkh.Checked; try { data.FamilyDeductionAmount = Int32.Parse(gtgc); data.SalaryScaleID = Int32.Parse(hsl); } catch { } var db = gen.GetNewEntity(); // khai bao new entity Framework { try { if (active == "0") { db.AccountingObjects.Add(data); //insert } else { db.Entry(data).State = System.Data.Entity.EntityState.Modified; // update } db.SaveChanges(); XtraMessageBox.Show("Submit successfully", "tsbtsave_Click", MessageBoxButtons.OK, MessageBoxIcon.Information); } //catch (DbUpdateException ex) // exception khac catch (DbUpdateConcurrencyException ex) // exception khac { XtraMessageBox.Show(ex.Message + ex.StackTrace + ex.TargetSite + ex.InnerException.Message + active, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSQL.Text = ex.Message + data + active; } } //lvpq.DataSource = data ; //txtSQL.Text = data.AccountingObjectID + data.AccountingObjectCode; }
private void baadd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { txtshd.Focus(); if (txtshd.Text == "") { XtraMessageBox.Show("Bạn chưa nhập Số hợp đồng.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (sekh.EditValue == null) { XtraMessageBox.Show("Bạn chưa chọn Khách hàng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //else if (denk.EditValue == null || dentd.EditValue == null || denl.EditValue==null || deng.EditValue==null || denqv.EditValue==null || dentl.EditValue==null) else if (denk.EditValue.ToString() == "" || dentd.EditValue.ToString() == "" || denl.EditValue.ToString() == "" || deng.EditValue.ToString() == "" || denqv.ToString() == "" || dentl.ToString() == "") { XtraMessageBox.Show("Ngày tháng năm bạn không được bỏ trống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txthmn.EditValue.ToString() == "" || txthn.EditValue.ToString() == "" || txthmtd.EditValue.ToString() == "") { XtraMessageBox.Show("Hạn mức nợ và Hạn nợ không được để trống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (active == "0") { try { gen.GetString("select * from ContractB where ContractCode=N'" + txtshd.EditValue + "'"); XtraMessageBox.Show("Hợp đồng này đã có trong hệ thống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } catch { } } //hd.checkhd(active, role, cblhd, txtshd, ledv, sekh, txtsdt, txtfax, txtndd, txtcv, txtguq, txtsgpkq, txtnc, txtltd, dentd, txtnh, txtstk, denk, denhh, txthmn, txthn, rbhdnt, rbhddh, rbtm, rbtc, rbbl, txtddgh, denl, deng, denqv, txtnl, chetl, dentl, chenqv, txthmtd); //XtraMessageBox.Show("Dữ liệu đã được cập nhật.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //update kieu moi /* * ContractB data = new ContractB();// lop ContractB * if (active == "0") * { * data.ContractID = Guid.NewGuid();// tao guiid moi * } * else * { * data.ContractID = Guid.Parse(role); * } * // data.ClientID = Globals.clientid; * data.CompanyCode = Globals.companycode; * data.ContractCode = txtshd.EditValue.ToString(); * data.ContractName = cblhd.EditValue.ToString(); * data.SignerName = txtndd.EditValue.ToString(); * data.Position = txtcv.EditValue.ToString(); * data.License = txtguq.EditValue.ToString(); * data.IssuedBy = txtnc.EditValue.ToString(); * data.Change = Int32.Parse(txtltd.EditValue.ToString()); * data.ChangeDate = DateTime.Parse(dentd.EditValue.ToString()); * data.CompanyTel = txtsdt.EditValue.ToString(); * data.CompanyFax = txtfax.EditValue.ToString(); * data.CompanyBankAccount = txtstk.EditValue.ToString(); * data.CompanyBankName = txtnh.EditValue.ToString(); * data.Proxy = txtsgpkq.EditValue.ToString(); * data.SignedDate = DateTime.Parse(denk.EditValue.ToString()); * data.EffectiveDate = DateTime.Parse(denhh.EditValue.ToString()); * data.DebtLimit = Decimal.Parse(txthmn.EditValue.ToString()); * data.LimitDate = Int32.Parse(txthn.EditValue.ToString()); * int hinhthuc = 1; * if (rbtc.Checked == true) * hinhthuc = 2; * else if (rbbl.Checked == true) * hinhthuc = 3; * data.NoPay = hinhthuc; * int loaihopdong = 1; * if (rbhddh.Checked == true) * loaihopdong = 2; * data.NoContract = loaihopdong; * data.DeliveryPlace = txtddgh.EditValue.ToString(); * data.Saved = txtnl.EditValue.ToString(); * data.Founded = DateTime.Parse(denl.EditValue.ToString()); * data.Send = DateTime.Parse(deng.EditValue.ToString()); * data.Received = DateTime.Parse(denqv.EditValue.ToString()); * int thanhly = 0; * if (chetl.Checked == true) * thanhly = 1; * data.Closed = thanhly; * data.ClosedDate = DateTime.Parse(dentl.EditValue.ToString()); * data.ParentContract = txtshd.EditValue.ToString(); * int ngayve = 0; * if (chenqv.Checked == true) * ngayve = 1; * data.Inactive = ngayve; * data.DebtLimitMax = Decimal.Parse(txthmtd.EditValue.ToString()); * * * // DebtLimitMax=N'" + txthmtd.EditValue + "' where ContractID='" + role + "'"); * string makho = gen.GetString("select StockID from Stock where StockCode='" + ledv.EditValue + "'"); * data.StockID = Guid.Parse(makho); * string makhach = gen.GetString("select AccountingObjectID from AccountingObject where AccountingObjectCode='" + sekh.EditValue + "'"); * data.AccountingObjectID = Guid.Parse(makhach); * using (hamacoEntities3 db = new hamacoEntities3()) * { * try * { * if (active == "0") db.ContractBs.Add(data); //insert * else db.Entry(data).State = System.Data.Entity.EntityState.Modified; // update * db.SaveChanges(); * XtraMessageBox.Show("Submit successfully", "tsbtsave_Click", MessageBoxButtons.OK, MessageBoxIcon.Information); * } * //catch (DbUpdateException ex) // exception khac * catch (DbUpdateConcurrencyException ex) // exception khac * { * XtraMessageBox.Show(ex.Message + ex.StackTrace + ex.TargetSite + ex.InnerException.Message + active, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); * //txtSQL.Text = ex.Message + data + active; * } * * } * * * * * * * myac(); * this.Close(); */ }
private void sbok_Click(object sender, EventArgs e) { if (checkEdit2.EditValue.ToString() == "True") { if (tsbt == "tsbtthpnxtt" || tsbt == "tsbtthpnxdc") { pnht.loadtong(ngaychungtu, userid, tsbt, "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG"); } else if (tsbt == "tsbtthuedaura" || tsbt == "tsbtthuedauvao") { bc.loadthuetong(ngaychungtu, tsbt, "intonghoptheokho", userid); } else if (tsbt == "tsbtthkqkd") { thtk.loadketquakinhdoanh(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), ngaychungtu, ngaycuoi, tsbt + "tct", userid); } else if (tsbt == "tsbtbkhhnd" || tsbt == "tsbtbkhhxd") { thtk.loadbangkehanghoatong(ngaychungtu, ngaycuoi, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "IDS").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Kho nhập").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Kho xuất").ToString(), "2"); } else if (tsbt == "tsbtpkt") { pkt.loadchitiet(ngaychungtu, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), "2", view.GetRowCellValue(view.FocusedRowHandle, "Tên người dùng").ToString(), tsbt + "tong", "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG"); } } else if (checkEdit1.EditValue.ToString() == "True") { if (tsbt == "tsbtbctcth") { if (tsbt == "tsbtbctcth") { thtk.loadbaocaothuchingay(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Tên kho").ToString()); } } else if (tsbt == "tsbtbkhhnd" || tsbt == "tsbtbkhhxd") { thtk.loadbangkehanghoatong(ngaychungtu, ngaycuoi, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "IDS").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Kho nhập").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Kho xuất").ToString(), "1"); } else if (tsbt == "tsbtthpnxtt" || tsbt == "tsbtthpnxdc") { pnht.loadchitiet(ngaychungtu, userid, tsbt, "1", "", "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG"); } else if (tsbt == "tsbtpkt") { pkt.loadchitiet(ngaychungtu, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), "0", view.GetRowCellValue(view.FocusedRowHandle, "Tên người dùng").ToString(), tsbt, "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG"); } else if (tsbt == "tsbtthkqkd") { thtk.loadketquakinhdoanh(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), ngaychungtu, ngaycuoi, tsbt + "tdv", userid); } else if (tsbt == "tsbtghiso") { string thang = DateTime.Parse(ngaychungtu).Month.ToString(); string nam = DateTime.Parse(ngaychungtu).Year.ToString(); if (XtraMessageBox.Show("Bạn có chắc ghi sổ toàn bộ dữ liệu tháng " + thang + " năm " + nam + " ?", "HAMACO", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { SplashScreenManager.ShowForm(typeof(Frm_wait)); gen.ExcuteNonquery("tonghopghiso '" + thang + "','" + nam + "','',1"); SplashScreenManager.CloseForm(); } } else if (tsbt == "tsbtboghi") { string thang = DateTime.Parse(ngaychungtu).Month.ToString(); string nam = DateTime.Parse(ngaychungtu).Year.ToString(); if (XtraMessageBox.Show("Bạn có chắc bỏ ghi toàn bộ dữ liệu tháng " + thang + " năm " + nam + " ?", "HAMACO", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { SplashScreenManager.ShowForm(typeof(Frm_wait)); gen.ExcuteNonquery("tonghopghiso '" + thang + "','" + nam + "','',0"); SplashScreenManager.CloseForm(); } } else if (tsbt == "tsbtthuedaura" || tsbt == "tsbtthuedauvao") { bc.loadthue(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "Mã khu vực").ToString(), "khuvuc", "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG", userid); } else if (tsbt == "sktth" || tsbt == "sktthtomtat") { string name = gen.GetString("select AccountName from Account where AccountNumber='" + userid + "'"); thtk.loadchitietsktth(ngaychungtu, ngaycuoi, tsbt, userid, name, ""); } else { thtk.loadchitietskttong(ngaychungtu, tsbt, account, accountname, lkno, lkco, cuoino, cuoico); } } else if (checkEdit3.EditValue.ToString() == "True") { if (tsbt == "tsbtthuedaura" || tsbt == "tsbtthuedauvao") { bc.loadthue(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), "intonghop", "", userid); } } else { if (tsbt == "tsbtbctcth") { thtk.loadbaocaothuchi(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Tên kho").ToString()); } else if (tsbt == "tsbtbkhhnd" || tsbt == "tsbtbkhhxd") { thtk.loadbangkehanghoa(ngaychungtu, ngaycuoi, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "IDS").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Kho nhập").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Kho xuất").ToString(), "0"); } else if (tsbt == "tsbtpkt") { pkt.loadchitiet(ngaychungtu, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), "1", view.GetRowCellValue(view.FocusedRowHandle, "Tên người dùng").ToString(), tsbt, "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG"); } else if (tsbt == "tsbtthpnxtt" || tsbt == "tsbtthpnxdc") { pnht.loadchitiet(ngaychungtu, userid, tsbt, "0", view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG"); } else if (tsbt == "tsbtthkqkd") { thtk.loadketquakinhdoanh(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), ngaychungtu, ngaycuoi, tsbt, userid); } else if (tsbt == "tsbtghiso") { string thang = DateTime.Parse(ngaychungtu).Month.ToString(); string nam = DateTime.Parse(ngaychungtu).Year.ToString(); if (XtraMessageBox.Show("Bạn có chắc ghi sổ dữ liệu kho " + view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString() + " tháng " + thang + " năm " + nam + " ?", "HAMACO", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { SplashScreenManager.ShowForm(typeof(Frm_wait)); gen.ExcuteNonquery("tonghopghiso '" + thang + "','" + nam + "','" + view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString() + "',1"); SplashScreenManager.CloseForm(); } } else if (tsbt == "tsbtboghi") { string thang = DateTime.Parse(ngaychungtu).Month.ToString(); string nam = DateTime.Parse(ngaychungtu).Year.ToString(); if (XtraMessageBox.Show("Bạn có chắc bỏ ghi dữ liệu kho " + view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString() + " tháng " + thang + " năm " + nam + " ?", "HAMACO", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { SplashScreenManager.ShowForm(typeof(Frm_wait)); gen.ExcuteNonquery("tonghopghiso '" + thang + "','" + nam + "','" + view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString() + "',0"); SplashScreenManager.CloseForm(); } } else if (tsbt == "tsbtthuedaura" || tsbt == "tsbtthuedauvao") { bc.loadthue(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), "kho", "CÔNG TY CỔ PHẦN VẬT TƯ HẬU GIANG", userid); } else if (tsbt == "sktth" || tsbt == "sktthtomtat") { string name = gen.GetString("select AccountName from Account where AccountNumber='" + userid + "'"); thtk.loadchitietsktth(ngaychungtu, ngaycuoi, tsbt, userid, name, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else if (tsbt == "tsbtctlv") { thtk.loadchitietlaivay(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Tên kho").ToString()); } else if (tsbt == "tsbtctlvtn") { thtk.loadchitietlaivaytheonganh(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Tên kho").ToString()); } else if (tsbt == "tsbtctkqkd" || tsbt == "tsbtctkqkdtt") { thtk.loadchitietkinhdoanh(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else if (tsbt == "bkthbhtnvkdlqh") { Frm_rpcongno rp = new Frm_rpcongno(); rp.getngaychungtu(ngaycuoi); rp.getkho(userid); rp.getuserid(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); rp.gettsbt(tsbt); rp.Show(); } else { thtk.loadchitietskt(ngaychungtu, tsbt, view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(), view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString() + " - " + view.GetRowCellValue(view.FocusedRowHandle, "Tên kho").ToString(), account, accountname); } } }
private void Frm_branch_Load(object sender, EventArgs e) { DataTable da = new DataTable(); DataTable temp1 = new DataTable(); temp1.Columns.Add("Mã tỉnh"); temp1.Columns.Add("Tên tỉnh"); da = gen.GetTable("select * from Province order by ProvinceName"); for (int i = 0; i < da.Rows.Count; i++) { DataRow dr = temp1.NewRow(); dr[0] = da.Rows[i][1].ToString(); dr[1] = da.Rows[i][2].ToString(); temp1.Rows.Add(dr); } leprovince.Properties.DataSource = temp1; leprovince.Properties.ValueMember = "Mã tỉnh"; leprovince.Properties.DisplayMember = "Tên tỉnh"; leprovince.EditValue = "CT"; radioButton1.Checked = true; DataTable dt1 = new DataTable(); DataTable temp9 = gen.GetTable("select InventoryCategoryCode as 'Mã ngành',InventoryCategoryName as 'Tên ngành' from InventoryItemCategory where IsParent=0 and Grade=3 order by InventoryCategoryCode"); dt1.Columns.Add("Mã ngành", Type.GetType("System.String")); dt1.Columns.Add("Tên ngành", Type.GetType("System.String")); dt1.Columns.Add("Hạn mức", Type.GetType("System.Double")); for (int i = 0; i < temp9.Rows.Count; i++) { DataRow dr = dt1.NewRow(); dr[0] = temp9.Rows[i][0].ToString(); dr[1] = temp9.Rows[i][1].ToString(); dt1.Rows.Add(dr); } DAT.DataSource = dt1; ViewDAT.OptionsBehavior.Editable = true; ViewDAT.Columns["Mã ngành"].OptionsColumn.AllowEdit = false; ViewDAT.Columns["Tên ngành"].OptionsColumn.AllowEdit = false; ViewDAT.Columns["Hạn mức"].OptionsColumn.AllowEdit = true; ViewDAT.Columns["Hạn mức"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom; ViewDAT.Columns["Hạn mức"].DisplayFormat.FormatString = "{0:n0}"; ViewDAT.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus; if (active == "1") { this.Text = "Sửa đơn vị"; //da = gen.GetTable("select * from Branch where BranchID='" + role + "'"); Guid branchid = Guid.Parse(role); var ctx = gen.GetNewEntity(); var query = ctx.Branches .Where(c => c.BranchID == branchid).OrderBy(c => c.BranchCode); foreach (var data in query) { txtcode.Text = data.BranchCode; txtname.Text = data.BranchName; txtdg.Text = data.Description; if (data.IsDependent == true) { radioButton1.Checked = true; } else { radioButton2.Checked = true; } } DataTable temp = new DataTable(); var query1 = ctx.Branches .Where(p => p.CompanyCode == Globals.companycode && p.BranchCode != txtcode.Text) .Select(p => new { p.BranchCode, p.BranchName }) .ToList(); temp = gen.ConvertToDataTable(query1); ledv.Properties.DataSource = temp; ledv.Properties.ValueMember = "BranchCode"; ledv.Properties.DisplayMember = "BranchCode"; //stock var query2 = ctx.Stocks.Where(c => c.CompanyCode == Globals.companycode) .Select(c => new { c.StockCode, c.StockName }) .ToList(); temp = gen.ConvertToDataTable(query2); lekho.Properties.DataSource = temp; lekho.Properties.ValueMember = "StockCode"; lekho.Properties.DisplayMember = "StockCode"; foreach (var data in query) { if (data.Parent != null) { string dv = gen.GetString("select BranchCode from Branch where BranchID='" + data.Parent.ToString() + "'"); ledv.EditValue = dv; } if (data.StockBranch != null) { string dv = gen.GetString("select StockCode from Stock where StockID='" + data.StockBranch + "'"); lekho.EditValue = dv; } leprovince.EditValue = data.Province; txtmst.Text = data.Code; // ma so thue } } else { this.Text = "Thêm đơn vị"; //da = gen.GetTable("select BranchCode,BranchName from Branch"); //chuyen sang dung kieu moi var db = gen.GetNewEntity(); // khai bao new entity Framework { var query = db.Branches .Where(p => p.CompanyCode == Globals.companycode) .Select(p => new { p.BranchCode, p.BranchName }) .ToList(); da = gen.ConvertToDataTable(query); } ledv.Properties.DataSource = da; ledv.Properties.ValueMember = "BranchCode"; ledv.Properties.DisplayMember = "BranchCode"; da = gen.GetTable("select StockCode,StockName from Stock"); lekho.Properties.DataSource = da; lekho.Properties.ValueMember = "StockCode"; lekho.Properties.DisplayMember = "StockCode"; lekho.ItemIndex = 0; } }
private void Frm_ddhcl_Load(object sender, EventArgs e) { DataTable da = gen.GetTable("select StockCode as 'Mã kho',StockName as 'Tên kho' from Stock a, MSC_UserJoinStock b where a.StockID=b.StockID and UserID='" + userid + "' order by StockCode"); sedv.Properties.DataSource = da; sedv.Properties.DisplayMember = "Mã kho"; sedv.Properties.ValueMember = "Mã kho"; sedv.EditValue = da.Rows[0][0].ToString(); DataTable temp = new DataTable(); temp.Columns.Add("Mã hàng"); temp.Columns.Add("Tên hàng"); for (int i = 0; i < hang.Rows.Count; i++) { DataRow dr = temp.NewRow(); dr[0] = hang.Rows[i][1].ToString(); dr[1] = hang.Rows[i][2].ToString(); temp.Rows.Add(dr); } semh.Properties.DataSource = temp; semh.Properties.DisplayMember = "Mã hàng"; semh.Properties.ValueMember = "Mã hàng"; denad.EditValue = DateTime.Parse(ngaychungtu); degd.EditValue = DateTime.Parse(ngaychungtu); txttl.EditValue = 0; txtdsd.EditValue = 0; if (Double.Parse(gen.GetString("select AuthenticationType from MSC_User where UserID='" + userid + "'")) > 1) { chenqv.Enabled = true; } if (active == "0") { sedv.Enabled = true; } else { sedv.Enabled = false; da = gen.GetTable("select RefNo,RefDate,PostedDate,StockCode,AccountingObjectCode,AccountingObjectName,TotalAmount,TotalTransport,IsExport,Contactname,Cancel from DDHCL a, Stock b where a.InStockID=b.StockID and RefID='" + role + "'"); txtsct.Text = da.Rows[0][0].ToString(); denad.EditValue = DateTime.Parse(da.Rows[0][1].ToString()); degd.EditValue = DateTime.Parse(da.Rows[0][2].ToString()); sedv.EditValue = da.Rows[0][3].ToString(); semh.EditValue = da.Rows[0][4].ToString(); txttl.EditValue = Double.Parse(da.Rows[0][6].ToString()); try { txtdsd.EditValue = Double.Parse(da.Rows[0][7].ToString()); } catch { } chenqv.Checked = bool.Parse(da.Rows[0][8].ToString()); lbduyet.Text = da.Rows[0][9].ToString(); if (da.Rows[0][8].ToString() == "True") { denad.Properties.ReadOnly = true; degd.Properties.ReadOnly = true; semh.Properties.ReadOnly = true; txttl.Properties.ReadOnly = true; txtdsd.Properties.ReadOnly = true; barcsddh.Enabled = true; } if (da.Rows[0][10].ToString() == "True") { barcsddh.Enabled = false; } } }
private void tsbtcat_Click(object sender, EventArgs e) { ledt.Focus(); hdmh.checkpck(active, role, this, gridView3, ledt, ledv, txtsct, txtname, txtdc, txtldn, denct, denht, ngaychungtu, cbthue, userid, branchid, txtms, txtkhhd, txtshd, txtnhd, txthtt, txthttt, txttthue, tsbttruoc, tsbtsau, txtquyen, ledvx); refreshrole(); click = "true"; change(); click = "false"; if (active == "1") { gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Sửa','" + txtsct.Text + "')"); } else { gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Thêm','" + txtsct.Text + "')"); } }
private void btok_Click(object sender, EventArgs e) { SplashScreenManager.ShowForm(typeof(Frm_wait)); /* try * {*/ string makho = ""; if (tsbt == "tsbtbctktsl" || tsbt == "tsbtbctktslcu" || tsbt == "tsbtbctktttt" || tsbt == "tsbtbctkthdtndn" || tsbt == "tsbtbctktttndn" || tsbt == "tsbtbctktttndntpxk" || tsbt == "tsbtbctktttndntaidv" || tsbt == "tsbtbctkvlpgtt" || tsbt == "tsbtbctkvlpgtndn" || tsbt == "tsbtbccn131" || tsbt == "tsbtbcptcn131" || tsbt == "tsbtbccn331" || tsbt == "tsbtbccn1313" || tsbt == "tsbtbccn3313" || tsbt == "tsbtbccn3388tdv" || tsbt == "tsbtbccn1388") { makho = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'"); } else { makho = gen.GetString("select * from Branch where BranchCode='" + ledv.EditValue.ToString() + "'"); } //báo cáo tồn kho theo hóa đơn if (tsbt == "tsbtbctktsl" || tsbt == "tsbtbctktslcu" || tsbt == "tsbtbctktttdv") { F.gettsbt(tsbt); F.refreshbaocao("tdv"); F.getdonvicongno(makho); myac(); this.Close(); } //báo cáo tồn kho theo hóa đơn từ ngày đến ngày else if (tsbt == "tsbtbctkthdtndn" || tsbt == "tsbtbctktndntdv") { F.gettsbt(tsbt); F.refreshbaocao("tdv"); F.getdonvicongno(makho); F.gettungay(detungay.EditValue.ToString()); F.getdenngay(dedenngay.EditValue.ToString()); myac(); this.Close(); // bctk.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); } else if (tsbt == "tsbtbctktndntct") { F.gettsbt(tsbt); F.refreshbaocao(tsbt); F.getdonvicongno(makho); F.gettungay(detungay.EditValue.ToString()); F.getdenngay(dedenngay.EditValue.ToString()); myac(); this.Close(); } //báo cáo tồn kho theo đơn vị /*else if (tsbt == "tsbtbctktttdv") * bctk.loadbctktsl(ngaychungtu, tsbt, makho);*/ //báo cáo tồn kho theo đơn vị từ ngày đến ngày //bctk.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); //báo cáo tồn kho theo đơn vị từ ngày đến ngày toàn công ty //bctk.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); //báo cáo tồn kho thực tế else if (tsbt == "tsbtbctktttt" || tsbt == "tsbtbctktttttdv") { F.gettsbt(tsbt); F.refreshbaocao("tdv"); F.getdonvicongno(makho); F.getdate(ngaychungtu); myac(); this.Close(); } //bctktt.loadbctktsl(ngaychungtu, tsbt, makho); //báo cáo tồn kho thực tế từ ngày đến ngày else if (tsbt == "tsbtbctktttndn" || tsbt == "tsbtbctktttndntpxk" || tsbt == "tsbtbctktttndntaidv") { bctktt.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); } //bctktt.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); //báo cáo tồn kho thực tế theo đơn vị //bctktt.loadbctktsl(ngaychungtu, tsbt, makho); //báo cáo tồn kho thực tế theo đơn vị từ ngày đến ngày else if (tsbt == "tsbtbctktttndntdv") { bctktt.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); } //báo cáo tồn kho thực tế toàn công ty else if (tsbt == "tsbtbctktttndntct") { bctktt.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); } else if (tsbt == "tsbtbctktttndnhgtct") { bctktt.loadbctkthdtndn(detungay, dedenngay, makho, tsbt); } //báo cáo tồn kho vỏ trong tháng else if (tsbt == "tsbtbctkvlpgtt" || tsbt == "tsbtbctkvlpgtttdv") { F.gettsbt(tsbt); F.refreshbaocao("tdv"); F.getdonvicongno(makho); myac(); this.Close(); } //báo cáo tồn kho vỏ từ ngày đến ngày else if (tsbt == "tsbtbctkvlpgtndn") { bctkv.loadbctkthdtndn(detungay, dedenngay, makho, tsbt, userid); } else if (tsbt == "tsbtbctkvlpgtndntdv") { bctkv.loadbctkthdtndn(detungay, dedenngay, makho, tsbt, userid); } else if (tsbt == "tsbtbctkvlpgtndntct") { bctkv.loadbctkthdtndn(detungay, dedenngay, makho, tsbt, userid); } else if (tsbt == "tsbtbccn131tdv" || tsbt == "tsbtbcptcn131tdv" || tsbt == "tsbtbccn1313tdv" || tsbt == "tsbtbccn3313tdv" || tsbt == "tsbtbccn331tdv" || tsbt == "tsbtbccn131" || tsbt == "tsbtbcptcn131" || tsbt == "tsbtbccn331" || tsbt == "tsbtbccn1313" || tsbt == "tsbtbccn3313" || tsbt == "tsbtbccn3388tdv" || tsbt == "tsbtbccn1388") { F.gettsbt(tsbt); F.refreshbaocao("tdv"); F.getdonvicongno(makho); myac(); this.Close(); } else if (tsbt == "tsbtbkhhnd" || tsbt == "tsbtbkhhxd") { Frm_chonkhotonghoptaikhoan u = new Frm_chonkhotonghoptaikhoan(); u.getuser(userid); u.getngaychungtu(detungay.EditValue.ToString()); u.getngaycuoi(DateTime.Parse(DateTime.Parse(dedenngay.EditValue.ToString()).AddDays(1).ToShortDateString()).AddSeconds(-1).ToString()); u.gettsbt(tsbt); u.ShowDialog(); } /*else if (tsbt == "tsbtbccn3313tdv") * { * F.getdonvicongno(makho); * myac(); * this.Close(); * }*/ SplashScreenManager.CloseForm(); /*} * catch * { * XtraMessageBox.Show("Vui lòng chọn kho trước khi xem tồn kho.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); * }*/ }
private void tsbtsave_Click(object sender, EventArgs e) { string branch = gen.GetString("select BranchID from Branch where BranchCode='" + cbbranch.EditValue.ToString() + "'"); string khochinh = gen.GetString("select StockID from Stock where StockCode='" + lekho.EditValue.ToString() + "'"); Stock data = new Stock(); if (active == "0") { data.StockID = Guid.NewGuid();// tao guiid moi } else { data.StockID = Guid.Parse(role); } //cac field khac null phai co //data.ClientID = Globals.clientid; data.CompanyCode = Globals.companycode; data.StockCode = txtcode.Text; // khong null data.StockName = txtname.Text; // khong null data.Description = txtdg.Text; data.BranchID = Guid.Parse(branch); data.Inactive = chbntd.Checked; // khong null data.LPG = LPG.Checked; data.Parent = Guid.Parse(khochinh); data.Province = leprovince.EditValue.ToString(); data.Code = txtmst.Text; data.InvName = txttcn.Text; data.Note = txtnote.Text; //txtSQL.Text = data.StockID + active; var db = gen.GetNewEntity(); // khai bao new entity Framework { try { if (active == "0") { db.Stocks.Add(data); //insert } else { db.Entry(data).State = System.Data.Entity.EntityState.Modified; // update } db.SaveChanges(); XtraMessageBox.Show("Submit successfully", "tsbtsave_Click", MessageBoxButtons.OK, MessageBoxIcon.Information); } //catch (DbUpdateException ex) // exception khac catch (DbUpdateException ex) // exception khac { XtraMessageBox.Show(ex.Message + ex.StackTrace + ex.TargetSite + ex.InnerException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSQL.Text = ex.Message + data.Province + data.StockID + active; } } /*if (active == "1") * { * string sql = "update Stock set StockName=N'" + txtname.Text + "',Description=N'" + txtdg.Text + "',BranchID='" + branch + "',Inactive='" + chbntd.Checked.ToString() + * "',LPG='"+LPG.Checked.ToString()+"',Parent='"+khochinh+"',Province='"+leprovince.EditValue.ToString()+"',Code='"+txtmst.Text+"',InvName=N'"+txttcn.Text+"', Note=N'"+txtnote.Text+"' where StockID='" + role + "'"; * stock.checkstock(active, txtcode, txtname, sql, this); * } * else * { * string sql = "insert into Stock values(newid(),'" + txtcode.Text + "',N'" + txtname.Text + "',N'" + txtdg.Text + "','" + branch + "','','False','"+LPG.Checked.ToString()+"','"+khochinh+"','"+leprovince.EditValue.ToString()+"','"+txtmst+"',N'"+txttcn.Text+"', N'"+txtnote.Text+"',NULL,NULL)"; * stock.checkstock(active, txtcode, txtname, sql, this); * }*/ }
private void Frm_rpbaocaotonkhothucte_Load(object sender, EventArgs e) { if (tsbt == "tsbtbctktttt" || tsbt == "tsbtbctktttttdv" || tsbt == "tsbtbctktttct") { rpbaocaotonkhothucte rpbaocaotonkho = new rpbaocaotonkhothucte(); string thang = String.Format("{0:MM}", DateTime.Parse(ngaychungtu)); string nam = DateTime.Parse(ngaychungtu).Year.ToString(); rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ THÁNG " + thang + " NĂM " + nam, tenkho, tungay, denngay, tsbt, kho); rpbaocaotonkho.BindData(dt); printControl1.PrintingSystem = rpbaocaotonkho.PrintingSystem; rpbaocaotonkho.CreateDocument(); } else if (tsbt == "tsbtbctkttttkm" || tsbt == "tsbtbctktttttdvkm" || tsbt == "tsbtbctktttctkm" || tsbt == "tsbtbctktttthgkm") { rpbaocaotonkhokm rpbaocaotonkho = new rpbaocaotonkhokm(); string thang = String.Format("{0:MM}", DateTime.Parse(ngaychungtu)); string nam = DateTime.Parse(ngaychungtu).Year.ToString(); if (tsbt == "tsbtbctktttthgkm") { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA HÀNG GỬI THÁNG " + thang + " NĂM " + nam, tenkho); } else if (gen.GetString("select CompanyTaxCode from Center") == "") { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA HÀNG CÔNG TY THÁNG " + thang + " NĂM " + nam, tenkho); } else { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA KHUYẾN MÃI THÁNG " + thang + " NĂM " + nam, tenkho); } rpbaocaotonkho.BindData(dt); printControl1.PrintingSystem = rpbaocaotonkho.PrintingSystem; rpbaocaotonkho.CreateDocument(); } else if (tsbt == "tsbtbctktttndnhg" || tsbt == "tsbtbctktttndnhctg") { this.Text = "Báo cáo tồn kho hàng hóa hàng gửi"; rpbaocaotonkhokm rpbaocaotonkho = new rpbaocaotonkhokm(); if (tsbt == "tsbtbctktttndnhg") { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA HÀNG GỬI TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho); } else if (tsbt == "tsbtbctktttndnhctg") { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA HÀNG CÔNG TY TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho); } rpbaocaotonkho.BindData(dt); printControl1.PrintingSystem = rpbaocaotonkho.PrintingSystem; rpbaocaotonkho.CreateDocument(); } else if (tsbt == "tsbtbctktttttdvhanggui" || tsbt == "tsbtbctktttttdvloaihanggui") { rpbaocaotonkhohanggui rpbaocaotonkho = new rpbaocaotonkhohanggui(); string thang = String.Format("{0:MM}", DateTime.Parse(ngaychungtu)); string nam = DateTime.Parse(ngaychungtu).Year.ToString(); rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THÁNG " + thang + " NĂM " + nam, tenkho); rpbaocaotonkho.BindData(dt); printControl1.PrintingSystem = rpbaocaotonkho.PrintingSystem; rpbaocaotonkho.CreateDocument(); } else if (tsbt == "bctknxtt") { rpbaocaotonkhohanggui rpbaocaotonkho = new rpbaocaotonkhohanggui(); rpbaocaotonkho.gettieude("BẢNG KÊ NHẬP XUẤT THỰC TẾ TỪ NGÀY " + String.Format("{0:dd/MM/yyyy}", DateTime.Parse(tungay)) + " ĐẾN NGÀY " + String.Format("{0:dd/MM/yyyy}", DateTime.Parse(denngay)), tenkho); rpbaocaotonkho.Bindxuatnhap(dt); printControl1.PrintingSystem = rpbaocaotonkho.PrintingSystem; rpbaocaotonkho.CreateDocument(); } else if (tsbt == "tsbtbctktttndntdvhanggui" || tsbt == "tsbtbctktttndntdvloaihanggui" || tsbt == "tsbtbctktttndnhgtcthanggui" || tsbt == "tsbtbctktttndntaidvhanggui") { rpbaocaotonkhohanggui rpbaocaotonkho = new rpbaocaotonkhohanggui(); if (tsbt == "tsbtbctktttndnhgtcthanggui") { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG GỬI TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho); } else if (tsbt == "tsbtbctktttndntaidvhanggui") { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho); } else { if (kho == "3") { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THEO PHIẾU XUẤT TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho); } else { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho); } } if (tsbt == "tsbtbctktttndntaidvhanggui") { rpbaocaotonkho.BindData(dt, "4" + ngaychungtu, kho); } else { rpbaocaotonkho.BindData(dt); } printControl1.PrintingSystem = rpbaocaotonkho.PrintingSystem; rpbaocaotonkho.CreateDocument(); } else { rpbaocaotonkhothucte rpbaocaotonkho = new rpbaocaotonkhothucte(); if (DateTime.Parse(tungay).Day == 1 && DateTime.Parse(denngay).Day == DateTime.DaysInMonth(DateTime.Parse(denngay).Year, DateTime.Parse(denngay).Month) && DateTime.Parse(tungay).Year == DateTime.Parse(denngay).Year) { if (DateTime.Parse(tungay).Month == 1 && DateTime.Parse(denngay).Month == 3) { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ QUÝ I NĂM " + DateTime.Parse(denngay).Year, tenkho, tungay, denngay, tsbt, kho); } else if (DateTime.Parse(tungay).Month == 4 && DateTime.Parse(denngay).Month == 6) { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ QUÝ II NĂM " + DateTime.Parse(denngay).Year, tenkho, tungay, denngay, tsbt, kho); } else if (DateTime.Parse(tungay).Month == 7 && DateTime.Parse(denngay).Month == 9) { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ QUÝ III NĂM " + DateTime.Parse(denngay).Year, tenkho, tungay, denngay, tsbt, kho); } else if (DateTime.Parse(tungay).Month == 10 && DateTime.Parse(denngay).Month == 12) { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ QUÝ IV NĂM " + DateTime.Parse(denngay).Year, tenkho, tungay, denngay, tsbt, kho); } else if (DateTime.Parse(tungay).Month == 1 && DateTime.Parse(denngay).Month == 12) { rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ NĂM " + DateTime.Parse(denngay).Year, tenkho, tungay, denngay, tsbt, kho); } else { tungay = String.Format("{0:dd/MM/yyy}", DateTime.Parse(tungay)); denngay = String.Format("{0:dd/MM/yyy}", DateTime.Parse(denngay)); rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho, tungay, denngay, tsbt, kho); } } else { tungay = String.Format("{0:dd/MM/yyy}", DateTime.Parse(tungay)); denngay = String.Format("{0:dd/MM/yyy}", DateTime.Parse(denngay)); rpbaocaotonkho.gettieude("BÁO CÁO TỒN KHO HÀNG HÓA THỰC TẾ TỪ NGÀY " + tungay + " ĐẾN NGÀY " + denngay, tenkho, tungay, denngay, tsbt, kho); } rpbaocaotonkho.BindData(dt); printControl1.PrintingSystem = rpbaocaotonkho.PrintingSystem; rpbaocaotonkho.CreateDocument(); } }
private void tsbtsave_Click(object sender, EventArgs e) { string loai = gen.GetString("select * from InventoryItemCategory where InventoryCategoryCode='" + leloai.EditValue.ToString().Trim() + "'"); int tc = Convert.ToInt32(letc.EditValue.ToString()); string thue = "0"; string tlcd, dgtk; if (txttlcd.Text == "") { tlcd = "NULL"; } else { tlcd = txttlcd.Text.Replace(".", "").Replace(",", "."); } if (txtdgtk.Text == "") { dgtk = "NULL"; } else { dgtk = txtdgtk.Text.Replace(".", "").Replace(",", "."); } if (txtcode.Text == "") { MessageBox.Show("Mã vật tư, hàng hóa không được bỏ trống.", "HAMACO"); } else if (txtname.Text == "") { MessageBox.Show("Tên vật tư hàng hóa không được bỏ trống.", "HAMACO"); } { if (active == "1") { try { string mb = gen.GetString("select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + lemb.Text + "'"); gen.ExcuteNonquery("update hamaco.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ", Parent='" + mb + "',SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_ta.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ", Parent='" + mb + "',SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_tn.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ", Parent='" + mb + "',SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_vithanh.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ", Parent='" + mb + "',SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_qlk.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ", Parent='" + mb + "',SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); } catch { gen.ExcuteNonquery("update hamaco.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ",SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_ta.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ",SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_tn.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ",SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_vithanh.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ",SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); gen.ExcuteNonquery("update hamaco_qlk.dbo.InventoryItem set InventoryItemName=N'" + txtname.Text + "',Unit=N'" + txtdvt.Text + "',ConvertUnit=N'" + txtdvcd.Text + "',ConvertRate=" + tlcd + ",GuarantyPeriod=N'" + txtthbh.Text + "',Inactive='" + chbntdoi.Checked.ToString() + "',InventoryCategoryID='" + loai + "',TaxRate='" + thue + "',InventoryItemType='" + tc + "',SalePrice=" + dgtk + ",SaleDescription=N'" + txtnganhhang.Text + "',PurchaseDescription=N'" + txtnhomhang.Text + "', IsSystem='" + chhkm.Checked + "' where InventoryItemCode='" + txtcode.Text + "'"); } this.myac(); this.Close(); } else { try { string mb = gen.GetString("select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + lemb.Text + "'"); ii.checkii(active, txtcode, txtname, "insert into hamaco.dbo.InventoryItem(InventoryItemID,InventoryCategoryID,InventoryItemCode,InventoryItemName,GuarantyPeriod,Unit,ConvertUnit,ConvertRate,SalePrice,TaxRate,InventoryItemType,Inactive,Parent,SaleDescription,PurchaseDescription,IsSystem) values(newid(),'" + loai + "','" + txtcode.Text + "',N'" + txtname.Text + "',N'" + txtthbh.Text + "',N'" + txtdvt.Text + "',N'" + txtdvcd.Text + "'," + tlcd + "," + dgtk + ",'" + thue + "','" + tc + "','" + chbntdoi.Checked.ToString() + "','" + mb + "',N'" + txtnganhhang.Text + "',N'" + txtnhomhang.Text + "','" + chhkm.Checked + "')", this); } catch { ii.checkii(active, txtcode, txtname, "insert into hamaco.dbo.InventoryItem(InventoryItemID,InventoryCategoryID,InventoryItemCode,InventoryItemName,GuarantyPeriod,Unit,ConvertUnit,ConvertRate,SalePrice,TaxRate,InventoryItemType,Inactive,SaleDescription,PurchaseDescription,IsSystem) values(newid(),'" + loai + "','" + txtcode.Text + "',N'" + txtname.Text + "',N'" + txtthbh.Text + "',N'" + txtdvt.Text + "',N'" + txtdvcd.Text + "'," + tlcd + "," + dgtk + ",'" + thue + "','" + tc + "','" + chbntdoi.Checked.ToString() + "',N'" + txtnganhhang.Text + "',N'" + txtnhomhang.Text + "','" + chhkm.Checked + "')", this); } } } }
private void login_user() { if (txtten.Text == "Tên đăng nhập" || txtten.Text == "") { XtraMessageBox.Show("Bạn chưa nhập tên đăng nhập.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtten.Focus(); } else if (txtmk.Text == "Mật khẩu" || txtmk.Text == "") { XtraMessageBox.Show("Bạn chưa nhập mật khẩu.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtmk.Focus(); }// else { try { //trong luc cho xu lý thì load frm_wait lên //SplashScreenManager.ShowForm(typeof(Frm_wait)); gencon gen = new gencon(); //XtraMessageBox.Show(Globals.constring, "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Error); string userid = ""; try { userid = gen.GetString("select Userid from MSC_User where UserName='******' and Password='******'"); if (userid != "") { this.Text = gen.GetString("select Top 1 CompanyName from Center"); Globals.userid = userid; //Globals.clientid = Int32.Parse(txtClient.Text); Globals.companycode = gen.GetString2("MSC_User", "CompanyCode", "Userid", userid); Globals.version = gen.GetString("select Version from Center where CompanyCode='" + Globals.companycode + "'"); Globals.username = txtten.Text.Replace("-", "").ToUpper(); Globals.companyname = this.Text; Globals.ngaychungtu = DateTime.Now.ToString(); //MainForm F = new MainForm(); Frm_Main F = new Frm_Main(); F.Show(); } else { XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng hay tk bị block", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { //XtraMessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng.", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtmk.Text = ""; txtmk.Focus(); XtraMessageBox.Show(ex.Message, "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Error); //SplashScreenManager.CloseForm(); } } catch { XtraMessageBox.Show("Kết nối DB không thành công", "HAMACO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void tsbtsave_Click(object sender, EventArgs e) { string code = txtma.Text; string name = txttc.Text.Replace("'", "''"); string branch = cbbranch.SelectedValue.ToString(); // branchID //string branchID = gen.GetString("select BranchID from Branch where BranchCode='" + branch + "'"); string dc = txtdc.Text.Replace("'", "''"); string mst = txtmst.Text; string dt = txtdt.Text; string fax = txtfax.Text; string web = txtwweb.Text; string email = txtemail.Text; if (txtemail.Text != "") { try { gen.GetString("select * from AccountingObject where AccountingObjectCode='" + txtemail.Text + "'"); } catch { XtraMessageBox.Show("Mã khách phụ không tồn tại vui lòng kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } string tknh = txttknh.Text; string tnh = txtnh.Text; string dg = txtdg.Text; string sntd = txtsntd.Text; string hn = txthn.Text; string tinh, quan; try { clsItem cls1 = (clsItem)cbprovince.SelectedItem; tinh = cls1.PstrValue; } catch { tinh = ""; } try { clsItem cls2 = (clsItem)cbdistrist.SelectedItem; quan = cls2.PstrValue; } catch { quan = ""; } string tencon = txttencon.Text.Replace("'", "''"); string chucdanh = txtcdcon.Text; string dccon = txtdccon.Text.Replace("'", "''"); string cmnd = txtscmnd.Text; DateTime ngaycap = dateTimePicker1.Value; string noicap = txtnccon.Text; string dtcq = txtdtcq.Text; string dtnr = txtdtnr.Text; string dtdd = txtdtdd.Text; string emailcon = txtemailcon.Text; string kh, ncc; if (rbkhncc.Checked == true) { kh = "True"; ncc = "True"; } else { kh = rbkh.Checked.ToString(); ncc = rbncc.Checked.ToString(); } string person = rbcn.Checked.ToString(); string ntd = chbntd.Checked.ToString(); string khncc; if (rbkhncc.Checked == true) { khncc = "Khách hàng; Nhà cung cấp"; } else { if (rbncc.Checked == true) { khncc = "Nhà cung cấp"; } else { khncc = "Khách hàng"; } } if (txtma.Text == "") { MessageBox.Show("Mã khách hàng, nhà cung cấp không được bỏ trống.", "HAMACO"); } else if (txttc.Text == "") { MessageBox.Show("Tên khách hàng, nhà cung cấp không được bỏ trống.", "HAMACO"); } /*else * { * if (active == "1") * { * try * { * string kq = gen.GetString("select * from hamaco.dbo.AccountingObject where CompanyTaxCode='" + txtmst.Text + "' and CompanyTaxCode<>'' and AccountingObjectCode<>'" + txtma.Text + "'"); * MessageBox.Show("Mã số thuế này đã tồn tại. Vui lòng kiểm tra lại.", "Thông báo"); * return; * } * catch * { * gen.ExcuteNonquery("update hamaco.dbo.AccountingObject set AccountingObjectName=N'" + name + "',BranchID='" + branchID + "',Address=N'" + dc + "',Tel='" + dt + "',Fax='" + fax + "',EmailAddress='" + email + "',Website=N'" + web + "',BankAccount='" + tknh + "',BankName=N'" + tnh + "',CompanyTaxCode='" + mst + "',Description=N'" + dg + "',ContactName=N'" + tencon + "',ContactTitle=N'" + chucdanh + "',ContactMobile='" + dtdd + "',ContactEmail='" + emailcon + "',ContactOfficeTel='" + dtcq + "',ContactHomeTel='" + dtnr + "',ContactAddress=N'" + dccon + "',IsPersonal='" + person + "',IdentificationNumber='" + cmnd + "',IssueDate='" + ngaycap + "',IssueBy=N'" + noicap + "',Inactive='" + ntd + "',DueTime='" + hn + "',MaximizeDebtAmount='" + sntd + "',IsVendor='" + ncc + "',IsCustomer='" + kh + "',Province='" + tinh + "',District='" + quan + "',AccountingObjectCategory=N'" + khncc + "',Village=N'" + cbprovince.Text + "' where AccountingObjectCode='" + txtma.Text + "'"); * gen.ExcuteNonquery("update hamaco_ta.dbo.AccountingObject set AccountingObjectName=N'" + name + "',BranchID='" + branchID + "',Address=N'" + dc + "',Tel='" + dt + "',Fax='" + fax + "',EmailAddress='" + email + "',Website=N'" + web + "',BankAccount='" + tknh + "',BankName=N'" + tnh + "',CompanyTaxCode='" + mst + "',Description=N'" + dg + "',ContactName=N'" + tencon + "',ContactTitle=N'" + chucdanh + "',ContactMobile='" + dtdd + "',ContactEmail='" + emailcon + "',ContactOfficeTel='" + dtcq + "',ContactHomeTel='" + dtnr + "',ContactAddress=N'" + dccon + "',IsPersonal='" + person + "',IdentificationNumber='" + cmnd + "',IssueDate='" + ngaycap + "',IssueBy=N'" + noicap + "',Inactive='" + ntd + "',DueTime='" + hn + "',MaximizeDebtAmount='" + sntd + "',IsVendor='" + ncc + "',IsCustomer='" + kh + "',Province='" + tinh + "',District='" + quan + "',AccountingObjectCategory=N'" + khncc + "',Village=N'" + cbprovince.Text + "' where AccountingObjectCode='" + txtma.Text + "'"); * gen.ExcuteNonquery("update hamaco_tn.dbo.AccountingObject set AccountingObjectName=N'" + name + "',BranchID='" + branchID + "',Address=N'" + dc + "',Tel='" + dt + "',Fax='" + fax + "',EmailAddress='" + email + "',Website=N'" + web + "',BankAccount='" + tknh + "',BankName=N'" + tnh + "',CompanyTaxCode='" + mst + "',Description=N'" + dg + "',ContactName=N'" + tencon + "',ContactTitle=N'" + chucdanh + "',ContactMobile='" + dtdd + "',ContactEmail='" + emailcon + "',ContactOfficeTel='" + dtcq + "',ContactHomeTel='" + dtnr + "',ContactAddress=N'" + dccon + "',IsPersonal='" + person + "',IdentificationNumber='" + cmnd + "',IssueDate='" + ngaycap + "',IssueBy=N'" + noicap + "',Inactive='" + ntd + "',DueTime='" + hn + "',MaximizeDebtAmount='" + sntd + "',IsVendor='" + ncc + "',IsCustomer='" + kh + "',Province='" + tinh + "',District='" + quan + "',AccountingObjectCategory=N'" + khncc + "',Village=N'" + cbprovince.Text + "' where AccountingObjectCode='" + txtma.Text + "'"); * gen.ExcuteNonquery("update hamaco_vithanh.dbo.AccountingObject set AccountingObjectName=N'" + name + "',BranchID='" + branchID + "',Address=N'" + dc + "',Tel='" + dt + "',Fax='" + fax + "',EmailAddress='" + email + "',Website=N'" + web + "',BankAccount='" + tknh + "',BankName=N'" + tnh + "',CompanyTaxCode='" + mst + "',Description=N'" + dg + "',ContactName=N'" + tencon + "',ContactTitle=N'" + chucdanh + "',ContactMobile='" + dtdd + "',ContactEmail='" + emailcon + "',ContactOfficeTel='" + dtcq + "',ContactHomeTel='" + dtnr + "',ContactAddress=N'" + dccon + "',IsPersonal='" + person + "',IdentificationNumber='" + cmnd + "',IssueDate='" + ngaycap + "',IssueBy=N'" + noicap + "',Inactive='" + ntd + "',DueTime='" + hn + "',MaximizeDebtAmount='" + sntd + "',IsVendor='" + ncc + "',IsCustomer='" + kh + "',Province='" + tinh + "',District='" + quan + "',AccountingObjectCategory=N'" + khncc + "',Village=N'" + cbprovince.Text + "' where AccountingObjectCode='" + txtma.Text + "'"); * //gen.ExcuteNonquery("update hamaco_qlk.dbo.AccountingObject set AccountingObjectName=N'" + name + "',BranchID='" + branchID + "',Address=N'" + dc + "',Tel='" + dt + "',Fax='" + fax + "',EmailAddress='" + email + "',Website=N'" + web + "',BankAccount='" + tknh + "',BankName=N'" + tnh + "',CompanyTaxCode='" + mst + "',Description=N'" + dg + "',ContactName=N'" + tencon + "',ContactTitle=N'" + chucdanh + "',ContactMobile='" + dtdd + "',ContactEmail='" + emailcon + "',ContactOfficeTel='" + dtcq + "',ContactHomeTel='" + dtnr + "',ContactAddress=N'" + dccon + "',IsPersonal='" + person + "',IdentificationNumber='" + cmnd + "',IssueDate='" + ngaycap + "',IssueBy=N'" + noicap + "',Inactive='" + ntd + "',DueTime='" + hn + "',MaximizeDebtAmount='" + sntd + "',IsVendor='" + ncc + "',IsCustomer='" + kh + "',Province='" + tinh + "',District='" + quan + "',AccountingObjectCategory=N'" + khncc + "',Village=N'" + cbprovince.Text + "' where AccountingObjectCode='" + txtma.Text + "'"); * this.myac(); * this.Close(); * } * } * else * { * try * { * string kq = gen.GetString("select * from hamaco.dbo.AccountingObject where CompanyTaxCode='" + txtmst.Text + "' and CompanyTaxCode<>''"); * MessageBox.Show("Mã số thuế này đã tồn tại. Vui lòng kiểm tra lại.", "Thông báo"); * return; * } * catch * { * string nv = "False"; * string insu = "False"; * string labe = "False"; * string sql = "insert into hamaco.dbo.AccountingObject(AccountingObjectID,AccountingObjectCode,AccountingObjectName,BranchID,Address,Tel,Fax,EmailAddress,Website,BankAccount,BankName,CompanyTaxCode,Description,ContactName,ContactTitle,ContactMobile,ContactEmail,ContactOfficeTel,ContactHomeTel,ContactAddress,IsPersonal,IdentificationNumber,IssueDate,IssueBy,Inactive,DueTime,MaximizeDebtAmount,IsVendor,IsCustomer,Province,District,IsEmployee,Insured,LabourUnionFee,FamilyDeductionAmount,AccountingObjectCategory,Village) values(newid(),'" + code + "',N'" + name + "','" + branchID + "',N'" + dc + "','" + dt + "','" + fax + "','" + email + "',N'" + web + "','" + tknh + "',N'" + tnh + "','" + mst + "',N'" + dg + "',N'" + tencon + "',N'" + chucdanh + "','" + dtdd + "','" + emailcon + "','" + dtcq + "','" + dtnr + "',N'" + dccon + "','" + person + "','" + cmnd + "','" + ngaycap + "',N'" + noicap + "','" + ntd + "','" + hn + "','" + sntd + "','" + ncc + "','" + kh + "','" + tinh + "','" + quan + "','" + nv + "','" + insu + "','" + labe + "','0',N'" + khncc + "',N'" + cbprovince.Text + "')"; * cuspro.checkcuspro(active, txtma, txttc, sql, this); * } * } * if (active == "1") * gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Sửa mã khách','" + txtma.Text + "')"); * else * gen.ExcuteNonquery("insert into MSC_Auditting_Log(EventID,LoginName,ComputerName,Time,PermissionTypeAlias,Reference) values(newid(),'" + gen.GetString("select UserName from MSC_User where UserID='" + userid + "'").ToString() + "','" + System.Environment.MachineName + "',GETDATE(),N'Thêm mã khách','" + txtma.Text + "')"); * }*/ AccountingObject data = new AccountingObject(); if (active == "0") { data.AccountingObjectID = Guid.NewGuid();// tao guiid moi } else { data.AccountingObjectID = Guid.Parse(role);; } //data.ClientID = Globals.clientid; data.CompanyCode = Globals.companycode; data.AccountingObjectCode = code; data.AccountingObjectName = name; //data.BranchID = Guid.Parse(branch); data.Address = dc; data.EmailAddress = email; data.BankAccount = tknh; data.BankName = tnh; data.CompanyTaxCode = mst; data.ContactTitle = chucdanh; data.ContactMobile = dtdd; data.ContactOfficeTel = dtcq; data.ContactHomeTel = dtnr; data.IsPersonal = true; data.IsEmployee = false; data.IdentificationNumber = cmnd; data.IssueDate = ngaycap; data.ContactTitle = chucdanh; data.IssueBy = noicap; data.Tel = txtdt.Text; data.Fax = txtfax.Text; data.Website = txtwweb.Text; data.Description = txtdg.Text; try { data.MaximizeDebtAmount = Int32.Parse(txtsntd.Text); data.DueTime = Int32.Parse(txthn.Text); } catch { } data.ContactName = txttencon.Text; data.ContactAddress = txtdccon.Text; data.ContactEmail = txtemailcon.Text; data.Inactive = chbntd.Checked; if (rbkhncc.Checked == true) { data.IsCustomer = true; data.IsVendor = true; } else { if (rbncc.Checked == true) { data.IsVendor = true; } else { data.IsCustomer = true; } } try { //data.BranchID = Guid.Parse(cbbranch.Text); data.BranchID = Guid.Parse(branch); } catch (Exception ex) { XtraMessageBox.Show(ex.Message + ex.StackTrace + ex.TargetSite + ex.InnerException.Message + active, "branch", MessageBoxButtons.OK, MessageBoxIcon.Error); } data.Inactive = chbntd.Checked; data.IsPersonal = rbcn.Checked; data.Province = tinh; data.District = quan; var db = gen.GetNewEntity(); // khai bao new entity Framework { try { if (active == "0") { db.AccountingObjects.Add(data); //insert } else { db.Entry(data).State = System.Data.Entity.EntityState.Modified; // update } db.SaveChanges(); XtraMessageBox.Show("Submit successfully", "tsbtsave_Click", MessageBoxButtons.OK, MessageBoxIcon.Information); } //catch (DbUpdateException ex) // exception khac catch (DbUpdateConcurrencyException ex) // exception khac { XtraMessageBox.Show(ex.Message + ex.StackTrace + ex.TargetSite + ex.InnerException.Message + active, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // txtSQL.Text = ex.Message + data + active; } } }
private void Frm_baocaotaichinh_Load(object sender, EventArgs e) { if (tsbt == "tsbthdbhchange" || tsbt == "tsbtddhlpgchange") { labelControl11.Text = "Mã khách cũ"; labelControl1.Text = "Mã khách mới"; textEdit1.Visible = false; searchLookUpEdit1.Visible = true; if (tsbt == "tsbthdbhchange") { DataTable dulieu = gen.GetTable("select AccountingObjectCode,a.BranchID, PURefDate,a.TotalAmount-a.TotalDiscountAmount-a.TotalFreightAmount+a.TotalVATAmount from SSInvoice a, AccountingObject b where a.AccountingObjectID=b.AccountingObjectID and RefID='" + ID + "'"); txtsct.Text = dulieu.Rows[0][0].ToString(); makho = dulieu.Rows[0][1].ToString(); //ngaychungtu = dulieu.Rows[0][2].ToString(); congno = Double.Parse(dulieu.Rows[0][3].ToString()); donvi = gen.GetString("select BranchID from Stock where StockID='" + makho + "'"); } else if (tsbt == "tsbtddhlpgchange") { txtsct.Text = gen.GetString("select AccountingObjectCode from INOutwardLPG a, AccountingObject b where a.AccountingObjectID=b.AccountingObjectID and RefID='" + ID + "'"); } searchLookUpEdit1.Properties.View.Columns.Clear(); DataTable temp = new DataTable(); temp.Columns.Add("Mã khách"); temp.Columns.Add("Tên khách"); temp.Columns.Add("Địa chỉ"); temp.Columns.Add("Mã số thuế"); for (int i = 0; i < khach.Rows.Count; i++) { DataRow dr = temp.NewRow(); dr[0] = khach.Rows[i][1].ToString(); dr[1] = khach.Rows[i][2].ToString(); dr[2] = khach.Rows[i][3].ToString(); dr[3] = khach.Rows[i][4].ToString(); temp.Rows.Add(dr); } searchLookUpEdit1.Properties.DataSource = temp; searchLookUpEdit1.Properties.DisplayMember = "Mã khách"; searchLookUpEdit1.Properties.ValueMember = "Mã khách"; searchLookUpEdit1.Focus(); } else { txtsct.Text = textEdit1.Text = chungtu; } }