private void butOk_Click(object sender, System.EventArgs e) { mmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); if (!ttb.bMmyy(mmyy)) { MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm 20" + mmyy.Substring(2) + " chưa tạo !", ttb.Msg); mm.Focus(); return; } xxx = user;//+ mmyy; if (ttb.bKhoaso(i_nhom, mmyy)) { MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2) + "\nĐã khóa không có phép thay đổi !", ttb.Msg); return; } if (makho.CheckedItems.Count == 0) { for (int i = 0; i < makho.Items.Count; i++) { makho.SetItemCheckState(i, CheckState.Checked); } } s_tenkho = ""; for (int i = 0; i < makho.Items.Count; i++) { if (makho.GetItemChecked(i)) { s_tenkho += dtkho.Rows[i]["ten"].ToString() + "\n"; } } if (MessageBox.Show("Bạn có đồng ý kiểm tra lại tồn đầu \n" + s_tenkho + "Tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2), ttb.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Cursor = Cursors.WaitCursor; string mmyyt = ttb.Mmyy_truoc(mmyy); if (!ttb.bKhoaso(i_nhom, mmyyt)) { ttb.upd_tonkho(mmyyt, i_nhom, 1); } for (int i = 0; i < makho.Items.Count; i++) { if (makho.GetItemChecked(i)) { ttb.upd_kiemtratondau(mmyy, int.Parse(dtkho.Rows[i]["id"].ToString()), i_userid); } } ttb.upd_tonkho(mmyy, i_nhom, 1); ttb.execute_data("delete from " + xxx + ".ttb_tonkhoct where tondau=0 and slnhap=0 and slxuat=0 and mmyy='" + mmyy + "'"); ttb.execute_data("delete from " + xxx + ".ttb_tonkhoth where tondau=0 and slnhap=0 and slxuat=0 and mmyy='" + mmyy + "'"); Cursor = Cursors.Default; MessageBox.Show("Đã kiểm tra lại tồn đầu \n" + s_tenkho, ttb.Msg); } }
private void frmButruc_Load(object sender, System.EventArgs e) { bKhoaso = ttb.bKhoaso(i_nhom, s_mmyy); format_soluong = ttb.format_soluong(i_nhom); format_dongia = ttb.format_dongia(i_nhom); format_sotien = ttb.format_sotien(i_nhom); dtdmbd = ttb.get_data("select * from ttb_dmbd where nhom=" + i_nhom + " order by id").Tables[0]; dtphieu = ttb.get_data("select * from ttb_loaiphieu where nhom=" + i_nhom + " and loai=" + i_loai + " order by stt").Tables[0]; phieu.DisplayMember = "TEN"; phieu.ValueMember = "ID"; phieu.DataSource = dtphieu; sql = "select * from d_duockp where nhom like '%" + i_nhom.ToString() + ",%'"; if (s_makp != "") { sql += " and id in (" + s_makp.Substring(0, s_makp.Length - 1) + ")"; } sql += " order by stt"; dtkp = ttb.get_data(sql).Tables[0]; makp.DisplayMember = "TEN"; makp.ValueMember = "ID"; makp.DataSource = dtkp; butChoduyet_Click(null, null); sql = "select distinct a.id,a.mabn,c.hoten,to_char(a.ngay,'dd/mm/yyyy') ngay,a.phieu,a.makp,a.idduyet,a.makhoa from ttb_xuatsdll a,ttb_bucstt b," + ttb.user + ".btdbn c "; sql += "where a.id=b.id and a.mabn=c.mabn and a.maql<>0 and a.loai=" + i_loai + " and a.nhom=" + i_nhom + " and a.mmyy='" + s_mmyy + "'"; if (ttb.bUserid) { sql += " and a.userid=" + i_userid; } if (ttb.bLoclinh) { sql += " and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'"; } if (s_makp != "") { sql += " and a.makhoa in (" + s_makp.Substring(0, s_makp.Length - 1) + ")"; } if (s_kho != "") { sql += " and b.makho in (" + s_kho.Substring(0, s_kho.Length - 1) + ")"; } sql += " order by a.id"; dtll = ttb.get_data(sql).Tables[0]; //s_mmyy mabn.DisplayMember = "MABN"; mabn.ValueMember = "ID"; mabn.DataSource = dtll; if (mabn.Items.Count > 0) { l_id = decimal.Parse(mabn.SelectedValue.ToString()); } else { l_id = 0; } load_head(); AddGridTableStyle(); }
private void frmHaophi_Load(object sender, System.EventArgs e) { //if (Screen.PrimaryScreen.WorkingArea.Width > 800) this.WindowState = System.Windows.Forms.FormWindowState.Normal; user = ttb.user; xxx = user;// +s_mmyy; // f_capnhat_db(); // bKhoaso = ttb.bKhoaso(i_nhom, s_mmyy); link = ttb.dbLink; string sField = ttb.f_get_select_field("ttb_dmbd", "image"); sql = "select " + sField.Trim().Trim(',') + " from " + user + ".ttb_dmbd where nhom=" + i_nhom + " order by id"; dtdmbd = ttb.get_data(sql).Tables[0]; dtphieu = ttb.get_data("select * from " + user + ".ttb_loaiphieu where nhom=" + i_nhom + " and loai=" + i_loai + " order by stt").Tables[0]; phieu.DisplayMember = "TEN"; phieu.ValueMember = "ID"; phieu.DataSource = dtphieu; sql = "select * from " + d.user + ".d_duockp where nhom like '%" + i_nhom.ToString() + ",%'"; if (s_makp != "") { sql += " and id in (" + s_makp.Substring(0, s_makp.Length - 1) + ")"; } sql += " order by stt"; dtkp = d.get_data(sql).Tables[0]; makp.DisplayMember = "TEN"; makp.ValueMember = "ID"; makp.DataSource = dtkp; butChoduyet_Click(null, null); sql = "select a.id,a.mabn,b.ten as hoten,to_char(a.ngay,'dd/mm/yyyy') as ngay,a.phieu,a.makp,a.idduyet,a.makhoa from " + xxx + ".ttb_xuatsdll a," + d.user + ".d_duockp" + link + " b "; sql += "where a.makp=b.id and a.loai=" + i_loai + " and a.nhom=" + i_nhom; if (ttb.bUserid) { sql += " and a.userid=" + i_userid; } if (ttb.bLoclinh) { sql += " and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'"; } if (s_makp != "") { sql += " and a.makp in (" + s_makp.Substring(0, s_makp.Length - 1) + ")"; } sql += " order by a.id"; dtll = ttb.get_data(sql).Tables[0]; mabn.DisplayMember = "MABN"; mabn.ValueMember = "ID"; mabn.DataSource = dtll; if (dtll.Rows.Count > 0) { l_id = decimal.Parse(mabn.SelectedValue.ToString()); } load_head(); AddGridTableStyle(); }
private void frmBuhaophi_Load(object sender, System.EventArgs e) { bKhoaso = ttb.bKhoaso(i_nhom, s_mmyy); dtdmbd = ttb.get_data("select * from ttb_dmbd where nhom=" + i_nhom + " order by id").Tables[0]; dtphieu = ttb.get_data("select * from ttb_loaiphieu where nhom=" + i_nhom + " and loai=4 order by stt").Tables[0]; phieu.DisplayMember = "TEN"; phieu.ValueMember = "ID"; phieu.DataSource = dtphieu; sql = "select * from d_duockp where nhom like '%" + i_nhom.ToString() + ",%'"; if (s_makp != "") { sql += " and id in (" + s_makp.Substring(0, s_makp.Length - 1) + ")"; } sql += " order by stt"; dtkp = ttb.get_data(sql).Tables[0]; makp.DisplayMember = "TEN"; makp.ValueMember = "ID"; makp.DataSource = dtkp; butChoduyet_Click(null, null); sql = "select a.id,a.mabn,b.ten hoten,to_char(a.ngay,'dd/mm/yyyy') ngay,a.phieu,a.makp,a.idduyet,a.makhoa from ttb_xuatsdll a," + ttb.user + ".d_duockp b," + ttb.user + ".ttb_loaiphieu c "; sql += "where a.makp=b.id and a.phieu=c.id and a.maql=0 and c.loai=4 and a.nhom=" + i_nhom + " and a.mmyy='" + s_mmyy + "'"; if (ttb.bUserid) { sql += " and a.userid=" + i_userid; } if (ttb.bLoclinh) { sql += " and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'"; } if (s_makp != "") { sql += " and a.makp in (" + s_makp.Substring(0, s_makp.Length - 1) + ")"; } sql += " order by a.id"; dtll = ttb.get_data(sql).Tables[0];//s_mmyy mabn.DisplayMember = "MABN"; mabn.ValueMember = "ID"; mabn.DataSource = dtll; if (dtll.Rows.Count > 0) { l_id = decimal.Parse(mabn.SelectedValue.ToString()); } load_head(); AddGridTableStyle(); }
private void butOk_Click(object sender, System.EventArgs e) { string mmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().Substring(2, 2); if (!ttb.bMmyy(mmyy)) { MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2) + " chưa tạo !", ttb.Msg); mm.Focus(); return; } if (ttb.bKhoaso(i_nhom, mmyy)) { MessageBox.Show("Số liệu tháng " + mmyy.Substring(0, 2) + " năm " + mmyy.Substring(2, 2) + " đã khóa !\nNếu cần thay đổi thì vào mục khai báo hệ thống", ttb.Msg); return; } if (MessageBox.Show("Bạn có đồng ý kiểm tra !", ttb.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Cursor = Cursors.WaitCursor; ttb.upd_tonkho(i_nhom, mmyy); Cursor = Cursors.Default; MessageBox.Show("Đã kiểm tra số liệu tồn kho !", ttb.Msg); } }
private void cmdOk_Click(object sender, System.EventArgs e) { ttb.setStandar(); string Ngaydemo = ttb.Ngaydemo("khottb"); if (Ngaydemo != "") { int songay = ttb.Songaydemo; if (songay != 0) { decimal conlai = songay - ttb.songay(ttb.StringToDate(ttb.ngayhienhanh_server.Substring(0, 10)), ttb.StringToDate(Ngaydemo), 0); if (conlai <= 0) { MessageBox.Show("Đã hết thời gian chạy thử\nLiên hệ nhà cung cấp:\nPhone : 08.7155019\nMobile : 090 3937066", ttb.Msg); return; } else if (conlai <= 3) { MessageBox.Show("Thời gian chạy thử còn " + conlai.ToString() + " ngày", ttb.Msg); } } } DataTable dtver = m.get_data("select * from version").Tables[0]; if (dtver.Rows.Count > 0) { if (dtver.Rows[0]["khottb"].ToString().Trim() != "") { string tenfile = ttb.file_exe("TrangThietBi"); if (dtver.Rows[0]["khottb"].ToString().Trim() != ttb.file_modify(tenfile)) { MessageBox.Show("Không đúng version đang sử dụng !", ttb.Msg); Application.Exit(); } } } if (!kiemtra()) { MessageBox.Show("Tên người dùng và mật khẩu không tìm thấy !", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtuser.Focus(); return; } mMmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().PadLeft(4, '0').Substring(2, 2); mNgay = ngay.Text; bool bKiemtra = false; string s_PassWord = txtpassword.Text; string s_PasswordLinks = "Links03031952@toancau" + DateTime.Now.ToString("ddMMyyyy"); iNhomkho = (int)LibDuoc.ID.NhomKho.TTB; if (txtuser.Text != LibTTB.AccessData.links_userid && s_PassWord != s_PasswordLinks) { if (!bTao && !ttb.bMmyy(mMmyy)) { MessageBox.Show("Bạn không có quyền tạo số liệu tháng mới !", ttb.Msg); return; } int iret = ttb.bKiemtrasolieu(iNhomkho, mMmyy, iUserid); if (iret == 0) { if (MessageBox.Show("Bạn có muốn tạo số liệu tháng " + mMmyy.Substring(0, 2) + " năm " + mMmyy.Substring(2, 2) + "?", ttb.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Cursor = Cursors.WaitCursor; string mmyyt = ttb.Mmyy_truoc(mMmyy); ttb.tao_partition(mMmyy); if (!ttb.bKhoaso(iNhomkho, mmyyt) && ttb.bAuto_tonkho(iNhomkho)) { bKiemtra = true; ttb.upd_tonkho(iNhomkho, mmyyt); } foreach (DataRow r in ttb.get_data("select * from " + user + ".ttb_dmkho where nhom=" + iNhomkho).Tables[0].Rows) { foreach (DataRow r1 in m.get_data("select * from " + m.user + ".d_duockp where nhom like '%" + iNhomkho.ToString() + ",%'").Tables[0].Rows) { ttb.upd_kiemtratutrucdau(mMmyy, int.Parse(r1["id"].ToString()), int.Parse(r["id"].ToString()), iUserid); } ttb.upd_kiemtratondau(mMmyy, int.Parse(r["id"].ToString()), iUserid); } ttb.upd_tonkho(mMmyy, iNhomkho, 0); ttb.upd_khoaso(iNhomkho, ttb.Mmyy_truoc(mMmyy), iUserid); ttb.upd_cosotutruc(iNhomkho, ttb.Mmyy_truoc(mMmyy), mMmyy); xxx = user; ttb.execute_data("delete from " + xxx + ".ttb_tonkhoct where tondau=0 and slnhap=0 and slxuat=0"); ttb.execute_data("delete from " + xxx + ".ttb_tonkhoth where tondau=0 and slnhap=0 and slxuat=0"); ttb.execute_data("delete from " + xxx + ".ttb_tutrucct where tondau=0 and slnhap=0 and slxuat=0"); ttb.execute_data("delete from " + xxx + ".ttb_tutructh where tondau=0 and slnhap=0 and slxuat=0"); Cursor = Cursors.Default; } else { return; } } else if (iret == -1) { return; } if (iNhomkho != 0 && !bKiemtra) { if (!ttb.bKhoaso(iNhomkho, mMmyy) && ttb.get_kiemtra(mMmyy, iNhomkho, ngay.Text)) { Cursor = Cursors.WaitCursor; ttb.upd_kiemtra(mMmyy, iNhomkho, ngay.Text, iUserid); ttb.upd_tonkho(iNhomkho, mMmyy); Cursor = Cursors.Default; } } } else { mUserid = LibTTB.AccessData.links_userid + LibTTB.AccessData.links_pass; } this.mExit = false; this.Close(); }