コード例 #1
0
 public void checksau(string sct, int vt, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, Frm_uynhiemchi F, string ngay, string userid)
 {
     try
     {
         tsbttruoc.Enabled = true;
         string id;
         if (vt == 0)
         {
             id = gen.GetString("select Top 1 * from BAAccreditative where RefNo > '" + sct + "' and Month(RefDate)='" + DateTime.Parse(ngay).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngay).Year.ToString() + "' and StockID in (select StockID from MSC_UserJoinStock where UserID='" + userid + "')  order by RefNo ASC");
         }
         else
         {
             id = gen.GetString("select Top 1 * from BAAccreditative where RefNo > '" + sct + "' and Month(RefDate)='" + DateTime.Parse(ngay).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngay).Year.ToString() + "' and StockID in (select StockID from MSC_UserJoinStock where UserID='" + userid + "') order by RefNo DESC");
             tsbtsau.Enabled = false;
         }
         F.getrole(id);
     }
     catch
     {
         tsbtsau.Enabled = false;
     }
 }
コード例 #2
0
 public void tsbtunc(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, DataTable khach)
 {
     try
     {
         Frm_uynhiemchi u = new Frm_uynhiemchi();
         u.myac = new Frm_uynhiemchi.ac(F.refreshunc);
         u.getactive(a);
         u.getsub(subsys);
         u.getroleid(roleid);
         u.getkhach(khach);
         u.getuser(userid);
         u.getdate(ngaychungtu);
         try
         {
             if (a == "1")
             {
                 u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString());
             }
         }
         catch { }
         u.ShowDialog();
     }
     catch { MessageBox.Show("Vui lòng chọn ủy nhiệm chi trước khi sửa."); }
 }
コード例 #3
0
        public void checkunc(string active, string role, Frm_uynhiemchi F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, LookUpEdit letk, LookUpEdit leth, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                             TextEdit txtnn, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, CheckEdit chvay,
                             ToolStripButton tsbtcat, ToolStripSplitButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, ComboBoxEdit cbthue, string userid, TextEdit txtthuhuong, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, string duyet)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                if (txtthuhuong.Text == "")
                {
                    txtthuhuong.Text = leth.Text;
                }
                string[,] detail = new string[50, 15];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Tài khoản có").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 0] = gridView1.GetRowCellValue(i, "Tài khoản có").ToString();
                    if (gridView1.GetRowCellValue(i, "Tài khoản nợ").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 1] = gridView1.GetRowCellValue(i, "Tài khoản nợ").ToString();

                    detail[i, 2] = "NULL";
                    if (gridView1.GetRowCellValue(i, "Ngày phát hành HĐ").ToString() != "")
                    {
                        detail[i, 2] = "'" + gridView1.GetRowCellValue(i, "Ngày phát hành HĐ").ToString() + "'";
                    }

                    detail[i, 3] = gridView1.GetRowCellValue(i, "Loại hóa đơn").ToString();
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Số hóa đơn").ToString();
                    if (gridView1.GetRowCellValue(i, "Số tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 5] = gridView1.GetRowCellValue(i, "Số tiền").ToString().Replace(".", "");

                    if (gridView1.GetRowCellValue(i, "Mã khách").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mk = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + gridView1.GetRowCellValue(i, "Mã khách").ToString() + "'");
                        detail[i, 6] = mk;
                    }
                    detail[i, 7] = gridView1.GetRowCellValue(i, "Diễn giải").ToString();
                    detail[i, 8] = gridView1.GetRowCellValue(i, "Ký hiệu hóa đơn").ToString();
                    detail[i, 9] = gridView1.GetRowCellValue(i, "Nhóm chi phí").ToString();
                }
                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Tài khoản có> <Tài khoản nợ> <Số tiền> <Mã Khách> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv   = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string tong = gridView1.Columns["Số tiền"].SummaryText;
                    tong = tong.Replace("Tổng tiền =", "").Trim();
                    tong = tong.Replace(".", "");

                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from BAAccreditative where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, tsbttruoc, tsbtsau, userid);
                            XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtsct.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch { }
                        gen.ExcuteNonquery("insert into BAAccreditative(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectBankAccount,AccountingObjectBankName,TotalAmount,Tax,UserID,Cancel,CustomField5,EditVersion) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtthuhuong.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "',N'" + letk.Text + "',N'" + txtnn.Text + "','" + tong + "','" + cbthue.Text + "','" + userid + "','" + chvay.Checked + "','" + txtsct.Text + "','" + duyet + "')");
                        string refid = gen.GetString("select * from BAAccreditative where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            /*if (detail[i, 2] == "")
                             * {
                             *  gen.ExcuteNonquery("insert into BAAccreditativeDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,SortOrder,CustomField5) values(newid(),'" + refid + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + i + ",'" + detail[i, 8] + "')");
                             * }
                             * else
                             * {*/
                            gen.ExcuteNonquery("insert into BAAccreditativeDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,CustomField5,CustomField4) values(newid(),'" + refid + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + detail[i, 2] + ",'" + detail[i, 3] + "','" + detail[i, 4] + "'," + i + ",'" + detail[i, 8] + "',N'" + detail[i, 9] + "')");
                            //}
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,Occupation,GroupCost) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + denct.EditValue.ToString() + "',N'" + detail[i, 7] + "',N'" + detail[i, 9] + "')");
                        }
                    }
                    else
                    {
                        if (duyet == "1")
                        {
                            if (gen.GetString("select EditVersion from BAAccreditative where RefID='" + role + "'") != "1")
                            {
                                themsctmoi(ngaychungtu, txtsct, tsbttruoc, tsbtsau, userid);
                            }
                        }

                        gen.ExcuteNonquery("update BAAccreditative set RefNo='" + txtsct.Text + "', RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtthuhuong.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectBankAccount=N'" + letk.Text + "',AccountingObjectBankName=N'" + txtnn.Text + "',TotalAmount='" + tong + "',Posted='False', Tax='" + cbthue.Text + "',UserID='" + userid + "', Cancel='" + chvay.Checked + "',EditVersion=" + duyet + "  where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  BAAccreditativeDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("insert into HACHTOANBK select *,GetDate() from HACHTOAN where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            /*if (detail[i, 2] == "")
                             * {
                             *  gen.ExcuteNonquery("insert into BAAccreditativeDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,SortOrder,CustomField5) values(newid(),'" + role + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + i + ",'" + detail[i, 8] + "')");
                             * }
                             * else
                             * {*/
                            gen.ExcuteNonquery("insert into BAAccreditativeDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,CustomField5,CustomField4) values(newid(),'" + role + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + detail[i, 2] + ",'" + detail[i, 3] + "','" + detail[i, 4] + "'," + i + ",'" + detail[i, 8] + "',N'" + detail[i, 9] + "')");
                            //}
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,Occupation,GroupCost) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + denct.EditValue.ToString() + "',N'" + detail[i, 7] + "',N'" + detail[i, 9] + "')");
                        }
                    }
                    F.getactive("1");
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }