Exemple #1
0
 public void checknhanvien(string ac, TextBox a, TextBox b, string sql, Frm_nhanvien F)
 {
     if (a.Text == "")
     {
         MessageBox.Show("Mã nhân viên không được bỏ trống.", "HAMACO");
     }
     else if (b.Text == "")
     {
         MessageBox.Show("Tên nhân viê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 AccountingObject where AccountingObjectCode='" + a.Text + "'");
                 MessageBox.Show("Mã nhân viên này đã tồn tại.", "HAMACO");
             }
             catch
             {
                 gen.ExcuteNonquery(sql);
                 F.myac();
                 F.Close();
             }
         }
     }
 }
Exemple #2
0
 public void checkstock(string ac, TextBox a, TextBox b, string sql, Frm_stock F)
 {
     if (a.Text == "")
     {
         MessageBox.Show("Mã kho không được bỏ trống.", "HAMACO");
     }
     else if (b.Text == "")
     {
         MessageBox.Show("Tên kho 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 Stock where StockCode='" + a.Text + "'");
                 MessageBox.Show("Mã kho này đã tồn tại.", "HAMACO");
             }
             catch
             {
                 gen.ExcuteNonquery(sql);
                 F.myac();
                 F.Close();
             }
         }
     }
 }
Exemple #3
0
 public void checkprovince(string ac, TextBox a, TextBox b, string sql, Frm_province F)
 {
     if (a.Text == "")
     {
         MessageBox.Show("Mã Tỉnh/Thành không được bỏ trống.", "HAMACO");
     }
     else if (b.Text == "")
     {
         MessageBox.Show("Tên Tỉnh/Thành 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 Province where ProvinceCode='" + a.Text + "'");
                 MessageBox.Show("Mã Tỉnh/Thành này đã tồn tại.", "HAMACO");
             }
             catch
             {
                 gen.ExcuteNonquery(sql);
                 F.myac();
                 F.Close();
             }
         }
     }
 }
Exemple #4
0
        public void find(string a, string b, string sql, Frm_iic F)
        {
            string m   = gen.GetString("select Grade from InventoryItemCategory where InventoryCategoryID='" + a + "'");
            string max = gen.GetString("select Grade from InventoryItemCategory where InventoryCategoryID='" + b + "'");
            int    con = int.Parse(m);
            int    cha = int.Parse(max);

            if (con >= cha)
            {
                if (a == b)
                {
                    MessageBox.Show("Không được chuyển mục này", "HAMACO");
                }
                else
                {
                    a = gen.GetString("select ParentID from InventoryItemCategory where InventoryCategoryID='" + a + "'");
                    find(a, b, sql, F);
                }
            }
            else
            {
                gen.ExcuteNonquery(sql);
                gen_ta.ExcuteNonquery(sql);
                gen_tn.ExcuteNonquery(sql);
                gen_chk_tp.ExcuteNonquery(sql);
                gen_chk_vt.ExcuteNonquery(sql);
                F.myac();
                F.Close();
            }
        }
Exemple #5
0
 public void tsbtdeleteckkh(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F)
 {
     try
     {
         string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString();
         if (XtraMessageBox.Show("Bạn có chắc muốn xóa tài sản " + view.GetRowCellValue(view.FocusedRowHandle, "Tên tài sản").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             gen.ExcuteNonquery("delete from Depreciation where DepreciationID='" + name + "'");
             view.DeleteRow(view.FocusedRowHandle);
         }
     }
     catch { XtraMessageBox.Show("Vui lòng chọn tài sản trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }
 }
Exemple #6
0
        public void checkhd(string active, string role, LookUpEdit lencc, LookUpEdit lencs, TextEdit txtscs, DateEdit detn, DateEdit dedn, TextEdit txttsl, TextEdit txtdsl, TextEdit txtck, RadioButton rbthang, RadioButton rbquy, RadioButton rbnam, RadioButton rbkg, RadioButton rbtan, MemoEdit txtnd, LabelControl lauser)
        {
            string theo = "Tháng";

            if (rbquy.Checked == true)
            {
                theo = "Quý";
            }
            if (rbnam.Checked == true)
            {
                theo = "Năm";
            }

            string donvitinh = "Kg";

            if (rbtan.Checked == true)
            {
                donvitinh = "Tấn";
            }


            if (active == "0")
            {
                try
                {
                    txtscs.Text = (Double.Parse(gen.GetString("select Max(PolicyCode) from  Policy")) + 1).ToString();
                }
                catch { txtscs.Text = "1"; }
                string cha = txtscs.Text;
                if (lencs.EditValue != null)
                {
                    cha = lencs.EditValue.ToString();
                }

                gen.ExcuteNonquery("insert into Policy(PolicyID,PolicyCode,InventoryItemCode,PolicyName,BeginDate,EndDate,Unit,Discount,PolicyParent,Species,BeginQuantity,EndQuantity,UserName)"
                                   + "values(newid(),'" + txtscs.Text + "','" + lencc.EditValue + "',N'" + txtnd.Text + "','" + detn.EditValue + "','" + dedn.EditValue + "',N'" + donvitinh + "','" + txtck.EditValue.ToString().Replace(".", "") + "','" + cha + "',N'" + theo + "','" + txttsl.EditValue.ToString().Replace(".", "") + "','" + txtdsl.EditValue.ToString().Replace(".", "") + "',N'" + lauser.Text + "')");
            }
            else
            {
                string cha = txtscs.Text;
                if (lencs.EditValue != null)
                {
                    cha = lencs.EditValue.ToString();
                }
                gen.ExcuteNonquery("update Policy set PolicyCode='" + txtscs.Text + "',InventoryItemCode='" + lencc.EditValue + "',PolicyName=N'" + txtnd.Text + "',BeginDate='" + detn.EditValue + "',EndDate='" + dedn.EditValue + "',Unit=N'" + donvitinh + "',Discount='" + txtck.EditValue.ToString().Replace(".", "") + "',PolicyParent='" + cha + "',Species=N'" + theo + "',BeginQuantity='" + txttsl.EditValue.ToString().Replace(".", "") + "',EndQuantity='" + txtdsl.EditValue.ToString().Replace(".", "") + "',UserName=N'" + lauser.Text + "' where PolicyID='" + role + "'");
            }
        }
Exemple #7
0
 public void checkcuspro(string ac, TextBox a, TextBox b, string sql, Frm_cuspro F)
 {
     try
     {
         string kq = gen.GetString("select * from hamaco.dbo.AccountingObject where AccountingObjectCode='" + a.Text + "'");
         MessageBox.Show("Mã khách hàng, nhà cung cấp này đã tồn tại.", "Thông báo");
     }
     catch
     {
         gen.ExcuteNonquery(sql);
         gen.ExcuteNonquery("insert into hamaco_ta.dbo.AccountingObject select * from hamaco.dbo.AccountingObject where AccountingObjectCode='" + a.Text + "'");
         gen.ExcuteNonquery("insert into hamaco_tn.dbo.AccountingObject select * from hamaco.dbo.AccountingObject where AccountingObjectCode='" + a.Text + "'");
         gen.ExcuteNonquery("insert into hamaco_vithanh.dbo.AccountingObject select * from hamaco.dbo.AccountingObject where AccountingObjectCode='" + a.Text + "'");
         //gen.ExcuteNonquery("insert into hamaco_qlk.dbo.AccountingObject select * from hamaco.dbo.AccountingObject where AccountingObjectCode='" + a.Text + "'");
         F.myac();
         F.Close();
     }
 }
Exemple #8
0
 public void checkaccount(string a, string sql, Frm_account F)
 {
     if (a == "")
     {
         MessageBox.Show("Tên tài khoản không được bỏ trống.", "HAMACO");
     }
     else
     {
         gen.ExcuteNonquery(sql);
         //gencon_vt.ExcuteNonquery(sql);
         //gen_ta.ExcuteNonquery(sql);
         //gen_tn.ExcuteNonquery(sql);
         //gen_tp.ExcuteNonquery(sql);
         //gen_vt.ExcuteNonquery(sql);
         //gen_vithanh.ExcuteNonquery(sql);
         F.myac();
         F.Close();
     }
 }
Exemple #9
0
 public void checkaccountgroup(string a, string sql, Frm_accountgroup F)
 {
     if (a == "")
     {
         MessageBox.Show("Tên tài khoản không được bỏ trống.", "HAMACO");
     }
     else
     {
         gen.ExcuteNonquery(sql);
         F.myac();
         F.Close();
     }
 }
Exemple #10
0
        public void checkhd(string active, string role, ComboBoxEdit cblhd, TextEdit txtshd, LookUpEdit ledv, SearchLookUpEdit sekh, TextEdit txtsdt, TextEdit txtfax, TextEdit txtndd, TextEdit txtcv, TextEdit txtguq, TextEdit txtsqpkd, MemoEdit txtnc, TextEdit txtltd, DateEdit dentd,
                            TextEdit txtnh, TextEdit txtstk, DateEdit denk, DateEdit denhh, TextEdit txthmn, TextEdit txthn, RadioButton rbhdnt, RadioButton rbhddh, RadioButton rbtm, RadioButton rbtc, RadioButton rbbl, MemoEdit txtddgh, DateEdit denl, DateEdit deng, DateEdit denqv, TextEdit txtnl, CheckEdit chetl, DateEdit dentl, CheckEdit chenqv, TextEdit txthmtd)
        {
            string makho       = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue + "'");
            string makhach     = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + sekh.EditValue + "'");
            int    loaihopdong = 1;

            if (rbhddh.Checked == true)
            {
                loaihopdong = 2;
            }
            int hinhthuc = 1;

            if (rbtc.Checked == true)
            {
                hinhthuc = 2;
            }
            else if (rbbl.Checked == true)
            {
                hinhthuc = 3;
            }
            int thanhly = 0;

            if (chetl.Checked == true)
            {
                thanhly = 1;
            }

            int ngayve = 0;

            if (chenqv.Checked == true)
            {
                ngayve = 1;
            }

            if (active == "0")
            {
                gen.ExcuteNonquery("insert ContractB(ContractID,ContractCode,ContractName,StockID,AccountingObjectID,SignerName,Position,License,IssuedBy,Change,ChangeDate,CompanyTel,CompanyFax,CompanyBankAccount,CompanyBankName,Proxy,SignedDate,EffectiveDate,DebtLimit,LimitDate,NoPay,NoContract,DeliveryPlace,Saved,Founded,Send,Received,Closed,ClosedDate,ParentContract,No,Inactive,DebtLimitMax)"
                                   + "values(newid(),N'" + txtshd.EditValue + "',N'" + cblhd.EditValue + "','" + makho + "','" + makhach + "',N'" + txtndd.EditValue + "',N'" + txtcv.EditValue + "',N'" + txtguq.EditValue + "',N'" + txtnc.EditValue + "',N'" + txtltd.EditValue + "','" + dentd.EditValue + "',N'" + txtsdt.EditValue + "',N'" + txtfax.EditValue + "',N'" + txtstk.EditValue + "',N'" + txtnh.EditValue + "',N'" + txtsqpkd.EditValue + "','" + denk.EditValue + "','" + denhh.EditValue + "',N'" + txthmn.EditValue + "',N'" + txthn.EditValue + "','" + hinhthuc + "','" + loaihopdong + "',N'" + txtddgh.EditValue + "',N'" + txtnl.EditValue + "','" + denl.EditValue + "','" + deng.EditValue + "','" + denqv.EditValue + "','" + thanhly + "','" + dentl.EditValue + "',N'" + txtshd.EditValue + "',0,'" + ngayve + "',N'" + txthmtd.EditValue.ToString().Replace(".", "") + "')");
            }
            else
            {
                gen.ExcuteNonquery("update ContractB set ContractCode=N'" + txtshd.EditValue + "',ContractName=N'" + cblhd.EditValue + "',StockID='" + makho + "',AccountingObjectID='" + makhach + "',SignerName=N'" + txtndd.EditValue + "',Position=N'" + txtcv.EditValue + "',License=N'" + txtguq.EditValue + "',IssuedBy=N'" + txtnc.EditValue + "',Change=N'" + txtltd.EditValue + "',ChangeDate=N'" + dentd.EditValue + "',CompanyTel=N'" + txtsdt.EditValue + "',CompanyFax=N'" + txtfax.EditValue + "',CompanyBankAccount=N'" + txtstk.EditValue + "',CompanyBankName=N'" + txtnh.EditValue + "',Proxy=N'" + txtsqpkd.EditValue + "',SignedDate='" + denk.EditValue + "',EffectiveDate='" + denhh.EditValue + "',DebtLimit='" + txthmn.EditValue + "',LimitDate='" + txthn.EditValue + "',NoPay=N'" + hinhthuc + "',NoContract=N'" + loaihopdong + "',DeliveryPlace=N'" + txtddgh.EditValue + "',Saved=N'" + txtnl.EditValue + "',Founded='" + denl.EditValue + "',Send='" + deng.EditValue + "',Received='" + denqv.EditValue + "',Closed='" + thanhly + "',ClosedDate='" + dentl.EditValue + "',ParentContract=N'" + txtshd.EditValue + "',Inactive='" + ngayve + "', DebtLimitMax=N'" + txthmtd.EditValue + "' where ContractID='" + role + "'");
            }
        }
Exemple #11
0
 public void checkii(string ac, DevExpress.XtraEditors.TextEdit a, DevExpress.XtraEditors.TextEdit b, string sql, Frm_ii F)
 {
     try
     {
         string kq = gen.GetString("select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + a.Text + "'");
         MessageBox.Show("Mã vật tư, hàng hóa này đã tồn tại.", "HAMACO");
     }
     catch
     {
         gen.ExcuteNonquery(sql);
         gen.ExcuteNonquery("insert into hamaco_ta.dbo.InventoryItem select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + a.Text + "'");
         gen.ExcuteNonquery("insert into hamaco_tn.dbo.InventoryItem select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + a.Text + "'");
         gen.ExcuteNonquery("insert into hamaco_vithanh.dbo.InventoryItem select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + a.Text + "'");
         gen.ExcuteNonquery("insert into hamaco_qlk.dbo.InventoryItem select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + a.Text + "'");
         F.myac();
         F.Close();
     }
 }
Exemple #12
0
        public void checkpnk(string active, string role, Frm_phieunhapvo F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                             TextEdit txtngh, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripSplitButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtmst, TextEdit txtptvc, string userid, string branchid, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, CheckEdit chtc)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 10];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 0] = mh;
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    detail[i, 3] = gridView1.GetRowCellValue(i, "Diễn giải").ToString();
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        detail[i, 4] = "0";
                    }
                    else
                    {
                        detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        detail[i, 5] = "0";
                    }
                    else
                    {
                        detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                    }

                    if (DateTime.Parse(ngaychungtu) < DateTime.Parse("09/01/2017"))
                    {
                        detail[i, 7] = gridView1.GetRowCellValue(i, "Tài khoản nợ").ToString();
                        detail[i, 6] = gridView1.GetRowCellValue(i, "Tài khoản có").ToString();
                    }
                    else
                    {
                        if (cbldt.EditValue.ToString() == "Khách hàng")
                        {
                            if (gridView1.GetRowCellValue(i, "Mượn").ToString() == "True")
                            {
                                detail[i, 7] = "131";
                                if (gridView1.GetRowCellValue(i, "Khác").ToString() == "True")
                                {
                                    detail[i, 6] = "34412";
                                }
                                else
                                {
                                    detail[i, 6] = "34411";
                                }
                            }
                            else if (gridView1.GetRowCellValue(i, "Trả").ToString() == "True")
                            {
                                detail[i, 6] = "131";
                                detail[i, 7] = "34411";
                            }
                            else
                            {
                                detail[i, 7] = "003";
                            }
                        }
                        else
                        {
                            if (gridView1.GetRowCellValue(i, "Mượn").ToString() == "True")
                            {
                                detail[i, 6] = "331";
                                if (gridView1.GetRowCellValue(i, "Khác").ToString() == "True")
                                {
                                    detail[i, 7] = "24412";
                                }
                                else
                                {
                                    detail[i, 7] = "24411";
                                }
                            }
                            else
                            {
                                detail[i, 7] = "003";
                            }
                        }
                    }

                    if (gridView1.GetRowCellValue(i, "Đơn giá BX").ToString() == "")
                    {
                        detail[i, 8] = "0";
                    }
                    else
                    {
                        detail[i, 8] = gridView1.GetRowCellValue(i, "Đơn giá BX").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Bốc xếp").ToString() == "")
                    {
                        detail[i, 9] = "0";
                    }
                    else
                    {
                        detail[i, 9] = gridView1.GetRowCellValue(i, "Bốc xếp").ToString().Replace(".", "").Replace(",", ".");
                    }
                }
                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    string dv = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string ldt;
                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }
                    string tongtien = gridView1.Columns["Thành tiền"].SummaryText.Replace(".", "");
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from INInwardSU where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);
                            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 INInwardSU(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,TotalAmount,UserID,InwardType) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + txtptvc.Text + "','" + tongtien + "','" + userid + "','" + chtc.Checked + "')");
                        string refid = gen.GetString("select * from INInwardSU where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            if (DateTime.Parse(ngaychungtu) < DateTime.Parse("09/01/2017"))
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 7] + "','" + detail[i, 6] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            }
                            else
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 7] + "','" + detail[i, 6] + "',0,'" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            }
                            gen.ExcuteNonquery("insert into INInwardSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPrice,Amount,DebitAccount,CreditAccount,UnitPriceConvertOC,AmountOC) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "',0,0,'" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 7] + "','" + detail[i, 6] + "','" + detail[i, 8] + "','" + detail[i, 9] + "')");
                        }
                    }
                    else
                    {
                        gen.ExcuteNonquery("update INInwardSU set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo='" + txtptvc.Text + "',TotalAmount='" + tongtien + "',UserID='" + userid + "', InwardType='" + chtc.Checked + "'  where RefID = '" + role + "'");
                        gen.ExcuteNonquery("delete  from  INInwardSUDetail where RefID ='" + role + "'");

                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            if (DateTime.Parse(ngaychungtu) < DateTime.Parse("09/01/2017"))
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 7] + "','" + detail[i, 6] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            }
                            else
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 7] + "','" + detail[i, 6] + "',0,'" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            }
                            gen.ExcuteNonquery("insert into INInwardSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPrice,Amount,DebitAccount,CreditAccount,UnitPriceConvertOC,AmountOC) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "',0,0,'" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 7] + "','" + detail[i, 6] + "','" + detail[i, 8] + "','" + detail[i, 9] + "')");
                        }
                    }
                    F.getactive("1");
                    F.Text = "Xem phiếu nhập kho Vỏ";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #13
0
        public void checkpnk(string active, string role, Frm_phieunhapkho F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                             TextEdit txtngh, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripSplitButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtmst, TextEdit txtptvc, string userid, string branchid, LookUpEdit lenv, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, CheckEdit cthg, CheckEdit chpck, string tsbt, CheckEdit chhtk, CheckEdit chtnm, CheckEdit chhgnb)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 10];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 0] = mh;
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        detail[i, 1] = "0";
                    }
                    else
                    {
                        detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString().Replace(".", "").Replace(",", ".");
                    detail[i, 3] = gridView1.GetRowCellValue(i, "Diễn giải").ToString();

                    if (gridView1.GetRowCellValue(i, "Số lượng tồn").ToString() == "")
                    {
                        detail[i, 4] = "0";
                    }
                    else
                    {
                        detail[i, 4] = gridView1.GetRowCellValue(i, "Số lượng tồn").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Số lượng quy đổi tồn").ToString() == "")
                    {
                        detail[i, 5] = "0";
                    }
                    else
                    {
                        detail[i, 5] = gridView1.GetRowCellValue(i, "Số lượng quy đổi tồn").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Đơn giá phí").ToString() == "")
                    {
                        detail[i, 6] = "0";
                    }
                    else
                    {
                        detail[i, 6] = gridView1.GetRowCellValue(i, "Đơn giá phí").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Bốc xếp").ToString() == "")
                    {
                        detail[i, 7] = "0";
                    }
                    else
                    {
                        detail[i, 7] = gridView1.GetRowCellValue(i, "Bốc xếp").ToString().Replace(".", "").Replace(",", ".");
                    }
                }
                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string ldt;
                    string hanggui = "0";
                    if (cthg.Checked == true)
                    {
                        hanggui = "1";
                    }
                    else if (chpck.Checked == true)
                    {
                        hanggui = "2";
                    }
                    else if (chhtk.Checked == true)
                    {
                        hanggui = "4";
                    }
                    else if (chtnm.Checked == true)
                    {
                        hanggui = "5";
                    }
                    else if (chhgnb.Checked == true)
                    {
                        hanggui = "6";
                    }
                    if (tsbt == "tsbtpxkhg" && chhtk.Checked == false && chtnm.Checked == false)
                    {
                        hanggui = "3";
                    }

                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }

                    string nv = "";
                    try
                    {
                        nv = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + lenv.EditValue.ToString() + "'");
                    }
                    catch { }

                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from INInwardTT where RefNo='" + txtsct.Text + "'");
                            if (tsbt == "tsbtpxkhg")
                            {
                                themsctxkhg(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);
                            }
                            else
                            {
                                themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);
                            }
                            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 { }
                        try
                        {
                            gen.ExcuteNonquery("insert into INInwardTT(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,EmployeeID,EmployeeIDPU) values(newid(),'" + hanggui + "','" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + txtptvc.Text + "','" + userid + "','" + nv + "')");
                        }
                        catch
                        {
                            gen.ExcuteNonquery("insert into INInwardTT(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,EmployeeID) values(newid(),'" + hanggui + "','" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + txtptvc.Text + "','" + userid + "')");
                        }
                        string refid = gen.GetString("select * from INInwardTT where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        F.getactive("1");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INInwardDetailTT(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPriceOC,UnitPriceConvert) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "',0,0,'" + detail[i, 6] + "','" + detail[i, 7] + "')");
                        }
                    }
                    else
                    {
                        try
                        {
                            gen.ExcuteNonquery("update INInwardTT set RefNo='" + txtsct.Text + "', RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo='" + txtptvc.Text + "',EmployeeID='" + userid + "',EmployeeIDPU='" + nv + "',RefType='" + hanggui + "'   where RefID='" + role + "'");
                        }
                        catch
                        {
                            gen.ExcuteNonquery("update INInwardTT set RefNo='" + txtsct.Text + "', RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo='" + txtptvc.Text + "',EmployeeID='" + userid + "',EmployeeIDPU=Null,RefType='" + hanggui + "'  where RefID='" + role + "'");
                        }
                        gen.ExcuteNonquery("delete  from  INInwardDetailTT where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INInwardDetailTT(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPriceOC,UnitPriceConvert) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 6] + "','" + detail[i, 7] + "')");
                        }

                        Double ton = 0;
                        try
                        {
                            ton = Double.Parse(gen.GetString("select sum(QuantityConvert-QuantityConvertExits) from INInwardDetailTT where RefID='" + role + "'"));
                        }
                        catch { }
                        if (ton == 0)
                        {
                            gen.ExcuteNonquery("update INInwardTT set IsExport='True' where RefID='" + role + "'");
                        }
                        else
                        {
                            gen.ExcuteNonquery("update INInwardTT set IsExport='False' where RefID='" + role + "'");
                        }
                    }
                    F.getactive("1");
                    F.Text = "Xem phiếu nhập kho";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #14
0
        //save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void checkpndc(string active, string role, Frm_phieunhaphangbantralai F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, TextEdit txtsct, TextEdit txtname,
                              TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                              ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtshd, TextEdit txtkhhd, TextEdit txtnhd, string userid, string branchid, TextEdit txtms, ComboBoxEdit cbthue, CheckEdit ckhd, string hoadon, TextEdit txtthue, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 8];

                for (int i = 0; i < gridView1.RowCount; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() != "")
                    {
                        detail[i, 0] = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                        {
                            detail[i, 1] = "0";
                        }
                        else
                        {
                            detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                        }
                        if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                        {
                            detail[i, 2] = "0";
                        }
                        else
                        {
                            detail[i, 2] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                        }
                        if (gridView1.GetRowCellValue(i, "Đơn giá phí").ToString() == "")
                        {
                            detail[i, 3] = "0";
                        }
                        else
                        {
                            detail[i, 3] = gridView1.GetRowCellValue(i, "Đơn giá phí").ToString().Replace(".", "").Replace(",", ".");
                        }
                        if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                        {
                            detail[i, 4] = "0";
                        }
                        else
                        {
                            detail[i, 4] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                        }
                        if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() == "")
                        {
                            detail[i, 5] = "0";
                        }
                        else
                        {
                            detail[i, 5] = gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString().Replace(".", "").Replace(",", ".");
                        }
                    }
                }

                string dv   = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                string tong = gridView1.Columns["Thành tiền"].SummaryText.Replace(".", "");
                if (active == "0")
                {
                    try
                    {
                        string ton = gen.GetString("select * from INReInward where RefNo='" + txtsct.Text + "'");
                        themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);
                        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 INReInward(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,JournalMemo,Posted,StockID,TotalAmount,InvSeries,InvNo,InvDate,EmployeeID,No,Tax,CheckIn,RefIn,TotalVATAmount) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtldn.Text + "','False','" + dv + "','" + tong + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + txtnhd.EditValue.ToString() + "','" + userid + "','" + txtms.Text + "','" + cbthue.EditValue.ToString() + "','" + ckhd.Checked.ToString() + "','" + hoadon + "','" + txtthue.Text.Replace(".", "") + "')");
                    string refid = gen.GetString("select * from INReInward where RefNo='" + txtsct.Text + "'");
                    gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','1561','632','" + tong + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");

                    /*gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate) values(newid(),'" + refid + "','" + txtsct.Text + "','531','131','" + tong + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "')");
                     * gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate) values(newid(),'" + refid + "','" + txtsct.Text + "','33311','131','" + txtthue.Text.Replace(".", "") + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "')");*/
                    F.getrole(refid);
                    if (ckhd.Checked == true)
                    {
                        for (int i = 0; i < gridView1.RowCount; i++)
                        {
                            try
                            {
                                gen.ExcuteNonquery("insert into INReInwardDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,UnitPriceCost,QuantityConvert) values(newid(),'" + refid + "',1561,632,'" + detail[i, 4] + "','" + detail[i, 1] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 2] + "','" + detail[i, 3] + "','" + detail[i, 5] + "')");
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < gridView1.RowCount; i++)
                        {
                            try
                            {
                                gen.ExcuteNonquery("insert into INReInwardDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,UnitPriceCost,QuantityConvert,DebitAccountIn,CreditAccountIn) values(newid(),'" + refid + "',1561,632,'" + detail[i, 4] + "','" + detail[i, 1] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 2] + "','" + detail[i, 3] + "','" + detail[i, 5] + "',531,632)");
                            }
                            catch {}
                        }
                    }
                }
                else
                {
                    gen.ExcuteNonquery("update INReInward set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',JournalMemo=N'" + txtldn.Text + "',StockID='" + dv + "',TotalAmount='" + tong + "',Posted='False',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',InvDate='" + txtnhd.EditValue.ToString() + "',EmployeeID='" + userid + "',No='" + txtms.Text + "',Tax='" + cbthue.EditValue.ToString() + "',CheckIn='" + ckhd.Checked.ToString() + "',RefIn='" + hoadon + "',TotalVATAmount='" + txtthue.Text.Replace(".", "") + "'  where RefID='" + role + "'");
                    gen.ExcuteNonquery("delete  from  INReInwardDetail where RefID='" + role + "'");
                    gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                    gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','156','632','" + tong + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");

                    /*gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate) values(newid(),'" + role + "','" + txtsct.Text + "','531','131','" + tong + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "')");
                     * gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate) values(newid(),'" + role + "','" + txtsct.Text + "','33311','131','" + txtthue.Text.Replace(".", "") + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "')");*/
                    if (ckhd.Checked == true)
                    {
                        for (int i = 0; i < gridView1.RowCount; i++)
                        {
                            try
                            {
                                gen.ExcuteNonquery("insert into INReInwardDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,UnitPriceCost,QuantityConvert) values(newid(),'" + role + "',1561,632,'" + detail[i, 4] + "','" + detail[i, 1] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 2] + "','" + detail[i, 3] + "','" + detail[i, 5] + "')");
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < gridView1.RowCount; i++)
                        {
                            try
                            {
                                gen.ExcuteNonquery("insert into INReInwardDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,UnitPriceCost,QuantityConvert,DebitAccountIn,CreditAccountIn) values(newid(),'" + role + "',1561,632,'" + detail[i, 4] + "','" + detail[i, 1] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 2] + "','" + detail[i, 3] + "','" + detail[i, 5] + "',531,632)");
                            }
                            catch { }
                        }
                    }
                }
                F.myac();
                F.getactive("1");
                F.Text = "Xem phiếu nhập hàng bán trả lại";
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #15
0
        //save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void checkpcnh(string active, string role, Frm_phieuthu F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                              TextEdit txtnn, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                              ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, ComboBoxEdit cbthue, string userid, TextEdit txthtt, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, SearchLookUpEdit danhmuc)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 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(".", "");
                    string ldt;
                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from BATransfer 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 BATransfer(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,UserID,ExDate,RefOrder) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "','" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "','" + userid + "','" + txthtt.EditValue.ToString() + "','" + danhmuc.EditValue.ToString() + "')");
                        string refid = gen.GetString("select * from BATransfer where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            /*if (detail[i, 2] == "")
                             * {
                             *  gen.ExcuteNonquery("insert into BATransferDetail(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 BATransferDetail(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() + "','" + detail[i, 7] + "',N'" + detail[i, 9] + "')");
                        }
                    }
                    else
                    {
                        gen.ExcuteNonquery("update BATransfer set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress='" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Posted='False', Tax='" + cbthue.Text + "',UserID='" + userid + "',ExDate='" + txthtt.EditValue.ToString() + "',RefOrder='" + danhmuc.EditValue.ToString() + "'  where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  BATransferDetail 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 BATransferDetail(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 BATransferDetail(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() + "','" + detail[i, 7] + "',N'" + detail[i, 9] + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu chi ngân hàng";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #16
0
//save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void checkpttm(string active, string role, Frm_phieuthu F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                              TextEdit txtnn, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                              ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, ComboBoxEdit cbthue, string userid, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, SearchLookUpEdit danhmuc, LookUpEdit letq, string duyet)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 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
                    {
                        try
                        {
                            DataTable mk = gen.GetTable("select AccountingObjectID,BranchID from AccountingObject where AccountingObjectCode='" + gridView1.GetRowCellValue(i, "Mã khách").ToString() + "'");
                            detail[i, 6] = mk.Rows[0][0].ToString();
                            if (gridView1.GetRowCellValue(i, "Tài khoản có").ToString() == "141")
                            {
                                detail[i, 8] = "'" + mk.Rows[0][1].ToString() + "'";
                            }
                            else
                            {
                                detail[i, 8] = "NULL";
                            }
                        }
                        catch
                        {
                            detail[i, 6] = gen.GetString("select AccountingObjectID from AccountingObject where AccountingObjectCode='" + gridView1.GetRowCellValue(i, "Mã khách").ToString() + "'");
                            detail[i, 8] = "NULL";
                        }
                    }
                    detail[i, 7]  = gridView1.GetRowCellValue(i, "Diễn giải").ToString();
                    detail[i, 9]  = gridView1.GetRowCellValue(i, "Ký hiệu hóa đơn").ToString();
                    detail[i, 10] = gridView1.GetRowCellValue(i, "Nhóm chi phí").ToString();
                    detail[i, 11] = gridView1.GetRowCellValue(i, "Ghi chú").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);
                    return;
                }
                else
                {
                    string dv   = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string dvtq = gen.GetString("select StockID from Stock where StockCode='" + letq.EditValue.ToString() + "'");
                    string tong = gridView1.Columns["Số tiền"].SummaryText;
                    tong = tong.Replace("Tổng tiền =", "").Trim();
                    tong = tong.Replace(".", "");
                    string ldt;
                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from CAReceipt where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, tsbttruoc, tsbtsau, userid, ledv.EditValue.ToString());
                        }
                        catch { }

                        gen.ExcuteNonquery("insert into CAReceipt(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,UserID,RefOrder,ShippingMethodID,EditVersion,CustomField5) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "','" + userid + "','" + danhmuc.EditValue.ToString() + "','" + dvtq + "'," + duyet + ",'" + txtsct.Text + "')");
                        string refid = gen.GetString("select * from CAReceipt where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            /*if (detail[i, 2] == "")
                            *  {
                            *   if (detail[i, 8] != "")
                            *       gen.ExcuteNonquery("insert into CAReceiptDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,SortOrder,StockID,CustomField5) values(newid(),'" + refid + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + i + ",'" + detail[i, 8] + "','" + detail[i, 9] + "')");
                            *   else
                            *       gen.ExcuteNonquery("insert into CAReceiptDetail(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, 9] + "')");
                            *  }
                            *  else
                            *  {
                            *   if (detail[i, 8] != "")*/
                            gen.ExcuteNonquery("insert into CAReceiptDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,StockID,CustomField5,CustomField4,Note) 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] + ",'" + detail[i, 9] + "',N'" + detail[i, 10] + "',N'" + detail[i, 11] + "')");

                            /*else
                             *  gen.ExcuteNonquery("insert into CAReceiptDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,CustomField5) 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, 9] + "')");
                             * }*/
                            if (duyet == "1" || duyet == "2")
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,Occupation,GroupCost,Goods) 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() + "','" + detail[i, 7] + "',N'" + detail[i, 10] + "','" + dvtq + "')");
                            }
                            else
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,Occupation,GroupCost,Goods) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 1] + "','','" + detail[i, 5] + "','" + detail[i, 6] + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + denct.EditValue.ToString() + "','" + detail[i, 7] + "',N'" + detail[i, 10] + "','" + dvtq + "')");
                            }
                        }
                    }
                    else
                    {
                        if (duyet == "2")
                        {
                            if (gen.GetString("select EditVersion from CAReceipt where RefID='" + role + "'") != "2")
                            {
                                themsctmoi(ngaychungtu, txtsct, tsbttruoc, tsbtsau, userid, ledv.EditValue.ToString());
                            }
                            tsbtcat.Visible = false;
                        }

                        gen.ExcuteNonquery("update CAReceipt set RefNo='" + txtsct.Text + "', RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Tax='" + cbthue.Text + "',UserID='" + userid + "',RefOrder='" + danhmuc.EditValue.ToString() + "',ShippingMethodID='" + dvtq + "',EditVersion=" + duyet + "  where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  CAReceiptDetail 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] == "")
                            *  {
                            *   if (detail[i, 8] != "")
                            *       gen.ExcuteNonquery("insert into CAReceiptDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,SortOrder,StockID,CustomField5) values(newid(),'" + role + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + i + ",'" + detail[i, 8] + "','" + detail[i, 9] + "')");
                            *   else
                            *       gen.ExcuteNonquery("insert into CAReceiptDetail(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, 9] + "')");
                            *  }
                            *  else
                            *  {
                            *   if (detail[i, 8] != "")*/
                            gen.ExcuteNonquery("insert into CAReceiptDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,StockID,CustomField5,CustomField4,Note) 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] + ",'" + detail[i, 9] + "',N'" + detail[i, 10] + "',N'" + detail[i, 11] + "')");

                            /*else
                             *  gen.ExcuteNonquery("insert into CAReceiptDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,CustomField5) 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, 9] + "')");
                             * }*/
                            if (duyet == "1" || duyet == "2")
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,Occupation,GroupCost,Goods) 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() + "','" + detail[i, 7] + "',N'" + detail[i, 10] + "','" + dvtq + "')");
                            }
                            else
                            {
                                gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,Occupation,GroupCost,Goods) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 1] + "','','" + detail[i, 5] + "','" + detail[i, 6] + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + denct.EditValue.ToString() + "','" + detail[i, 7] + "',N'" + detail[i, 10] + "','" + dvtq + "')");
                            }
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu thu tiền mặt";
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message + ex.StackTrace + ex.TargetSite.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemple #17
0
 //luu trữ những thay dổi khi check
 public void checkinfo(string a, string b, string sql, FRM_MSCROLE F, string c, string role)
 {
     if (a == "")
     {
         MessageBox.Show("Mã vai trò không được bỏ trống.", "HAMACO");
     }
     else if (b == "")
     {
         MessageBox.Show("Tên vai trò không được bỏ trống.", "HAMACO");
     }
     else
     {
         if (c == "0")
         {
             try
             {
                 string kq = gen.GetString("select * from MSC_Role where RoleCode='" + a + "'");
                 MessageBox.Show("Vai trò này đã tồn tại.", "HAMACO");
             }
             catch
             {
                 gen.ExcuteNonquery(sql);
                 string    id = gen.GetString("select * from MSC_Role where RoleCode='" + a + "'");
                 DataTable da = new DataTable();
                 da = gen.GetTable("select * from MSC_RolePermissionMaping where RoleID='" + role + "'");
                 for (int i = 0; i < da.Rows.Count; i++)
                 {
                     gen.ExcuteNonquery("insert into MSC_RolePermissionMaping values(newid(),'" + da.Rows[i][1].ToString() + "','" + id + "','" + da.Rows[i][3].ToString() + "')");
                 }
                 F.myac();
                 F.Close();
             }
         }
         else
         {
             gen.ExcuteNonquery(sql);
             F.myac();
             F.Close();
         }
     }
 }
Exemple #18
0
 public void checkbranch(string ac, TextBox a, TextBox b, Frm_branch F, DevExpress.XtraEditors.LookUpEdit ledv, TextBox txtdg, RadioButton radioButton1, string role, DevExpress.XtraEditors.LookUpEdit lekho, DevExpress.XtraEditors.LookUpEdit leprovince, TextBox txtmst)
 {
     if (a.Text == "")
     {
         MessageBox.Show("Mã đơn vị không được bỏ trống.", "HAMACO");
     }
     else if (b.Text == "")
     {
         MessageBox.Show("Tên đơn vị không được bỏ trống.", "HAMACO");
     }
     else
     {
         string sql, dv;
         string th  = radioButton1.Checked.ToString();
         string kho = gen.GetString("select * from Stock where StockCode='" + lekho.EditValue + "'");
         if (ac == "1")
         {
             try
             {
                 dv = ledv.EditValue.ToString();
                 DataTable temp = new DataTable();
                 temp = gen.GetTable("select * from Branch where BranchCode='" + dv + "'");
                 dv   = temp.Rows[0][0].ToString();
                 int bac = Int32.Parse(temp.Rows[0][9].ToString()) + 1;
                 sql = "update Branch set BranchCode=N'" + a.Text + "', BranchName=N'" + b.Text + "',Description=N'" + txtdg.Text + "',IsDependent='" + th + "',Parent='" + dv + "',Grade=" + bac + ",StockBranch='" + kho + "',Province='" + leprovince.EditValue.ToString() + "',Code='" + txtmst.Text + "' where BranchID='" + role + "'";
                 gen.ExcuteNonquery("update Branch set IsParent='True' where BranchID='" + dv + "'");
             }
             catch
             {
                 sql = "update Branch set BranchCode=N'" + a.Text + "', BranchName=N'" + b.Text + "',Description=N'" + txtdg.Text + "',IsDependent='" + th + "',Parent=NULL,Grade=1,StockBranch='" + kho + "',Province='" + leprovince.EditValue.ToString() + "',Code='" + txtmst.Text + "' where BranchID='" + role + "'";
             }
             gen.ExcuteNonquery(sql);
             F.myac();
             F.Close();
         }
         else
         {
             try
             {
                 string kq = gen.GetString("select * from Branch where BranchCode='" + a.Text + "'");
                 MessageBox.Show("Mã đơn vị này đã tồn tại.", "HAMACO");
             }
             catch
             {
                 try
                 {
                     dv = ledv.EditValue.ToString();
                     DataTable temp = new DataTable();
                     temp = gen.GetTable("select * from Branch where BranchCode='" + dv + "'");
                     dv   = temp.Rows[0][0].ToString();
                     int bac = Int32.Parse(temp.Rows[0][9].ToString()) + 1;
                     sql = "insert into Branch values(newid(),'" + a.Text + "',N'" + b.Text + "',N'" + txtdg.Text + "','" + th + "','False','False','False','" + dv + "'," + bac + ",'" + kho + "','" + leprovince.EditValue.ToString() + "','" + txtmst.Text + "')";
                     gen.ExcuteNonquery("update Branch set IsParent='True' where BranchID='" + dv + "'");
                 }
                 catch
                 {
                     sql = "insert into Branch values(newid(),'" + a.Text + "',N'" + b.Text + "',N'" + txtdg.Text + "','" + th + "','False','False','False',NULL,1,'" + kho + "','" + leprovince.EditValue.ToString() + "','" + txtmst.Text + "')";
                 }
                 gen.ExcuteNonquery(sql);
                 F.myac();
                 F.Close();
             }
         }
     }
 }
Exemple #19
0
        //save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void checkpctmvt(string active, string role, Frm_phieuthuvt F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                                TextEdit txtnn, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                                ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, ComboBoxEdit cbthue, TextEdit txtshd, TextEdit txtkhhd, TextEdit txtnhd, string userid, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 8];
                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();
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 2] = mh;
                    }

                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 3] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                }
                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ợ> <Mã hàng> <Số lượng> <Đơn giá> <Thành tiền> !", "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["Thành tiền"].SummaryText;
                    tong = tong.Replace(".", "");
                    string ldt;
                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }
                    string nhd = txtnhd.Text;
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from SUCAPayment where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), tsbttruoc, tsbtsau);
                            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 { }
                        if (nhd == "")
                        {
                            gen.ExcuteNonquery("insert into SUCAPayment(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,InvSeries,InvNo,EmployeeID) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "','" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + userid + "')");
                        }
                        else
                        {
                            gen.ExcuteNonquery("insert into SUCAPayment(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,InvDate,InvSeries,InvNo,EmployeeID) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "','" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "','" + txtnhd.EditValue.ToString() + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + userid + "')");
                        }
                        string refid = gen.GetString("select * from SUCAPayment where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into SUCAPaymentDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,SalePrice) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,Goods) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + dv + "')");
                        }
                    }
                    else
                    {
                        if (nhd == "")
                        {
                            gen.ExcuteNonquery("update SUCAPayment set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress='" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Posted='False',Tax='" + cbthue.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',EmployeeID='" + userid + "'  where RefID='" + role + "'");
                        }
                        else
                        {
                            gen.ExcuteNonquery("update SUCAPayment set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress='" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Posted='False',Tax='" + cbthue.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',InvDate='" + txtnhd.EditValue.ToString() + "',EmployeeID='" + userid + "'  where RefID='" + role + "'");
                        }
                        gen.ExcuteNonquery("delete  from  SUCAPaymentDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into SUCAPaymentDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,SalePrice) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,Goods) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + dv + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu thu tiền mặt bán vật tư";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #20
0
        public void checkpck(string active, string role, Frm_chuyenkhonb F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, LookUpEdit ledvn, TextEdit txtsct, TextEdit txtname, TextEdit txtngh, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtptvc, string userid, string branchid, TextEdit txtpnv, TextEdit txtms, TextEdit txtkhhd, TextEdit txtshd, TextEdit txtnhd, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, string bat)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 8];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 0] = mh;
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        detail[i, 1] = "0";
                    }
                    else
                    {
                        detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    }
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        detail[i, 4] = "0";
                    }
                    else
                    {
                        detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        detail[i, 5] = "0";
                    }
                    else
                    {
                        detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                    }
                    detail[i, 3] = gridView1.GetRowCellValue(i, "Diễn giải").ToString();
                }

                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv       = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string dvn      = gen.GetString("select * from Stock where StockCode='" + ledvn.EditValue.ToString() + "'");
                    string tongtien = gridView1.Columns["Thành tiền"].SummaryText.Replace(".", "");
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from INTransferBranchSU where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), tsbttruoc, tsbtsau);
                            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 { }

                        try
                        {
                            string ton = gen.GetString("select * from INTransferBranchSU where RefNoIn='" + txtpnv.Text + "'");
                            themsctn(ngaychungtu, txtpnv, ledvn.EditValue.ToString());
                            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 INTransferBranchSU(RefID,RefType,RefDate,PostedDate,RefNo,RefNoIn,AccountingObjectID,AccountingObjectName,Contactname,JournalMemo,Posted,OutwardStockID,InwardStockID,ShippingNo,TotalAmount,No,InvSeries,InvNo,InvDate) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + txtpnv.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "','False','" + dv + "','" + dvn + "','" + txtptvc.Text + "','" + tongtien + "','" + txtms.Text + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + txtnhd.EditValue.ToString() + "')");
                        string refid = gen.GetString("select * from INTransferBranchSU where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        if (DateTime.Parse(ngaychungtu) < DateTime.Parse("09/01/2017"))
                        {
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','336','1563','" + tongtien + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtpnv.Text + "','1563','336','" + tongtien + "','" + dt + "','" + dvn + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        }
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INTransferBranchSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,UnitPrice,Amount) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 4] + "','" + detail[i, 5] + "')");
                        }
                    }
                    else
                    {
                        if (bat == "1")
                        {
                            try
                            {
                                string ton = gen.GetString("select * from INTransferBranchSU where RefNoIn='" + txtpnv.Text + "'");
                                themsctn(ngaychungtu, txtpnv, ledvn.EditValue.ToString());
                                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("update INTransferBranchSU set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',RefNoIn='" + txtpnv.Text + "',InwardStockID='" + dvn + "',Posted='False',ShippingNo='" + txtptvc.Text + "',TotalAmount='" + tongtien + "',No='" + txtms.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',InvDate='" + txtnhd.EditValue.ToString() + "'  where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  INTransferBranchSUDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        if (DateTime.Parse(ngaychungtu) < DateTime.Parse("09/01/2017"))
                        {
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','336','1563','" + tongtien + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtpnv.Text + "','1563','336','" + tongtien + "','" + dt + "','" + dvn + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        }
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INTransferBranchSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,UnitPrice,Amount) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 4] + "','" + detail[i, 5] + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu xuất hàng gửi bán vỏ LPG";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #21
0
 //save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public void checkpxht(string active, string role, Frm_phieudieuchinh F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, TextEdit txtsct, TextEdit txtname,
                       TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                       ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtshd, TextEdit txtkhhd, TextEdit txtnhd, string userid, string branchid, TextEdit txtms)
 {
     try
     {
         string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
         string[,] detail = new string[20, 8];
         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();
             if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
             {
                 check = "1";
             }
             else
             {
                 string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                 detail[i, 2] = mh;
             }
             if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
             {
                 detail[i, 3] = "0";
             }
             else
             {
                 detail[i, 3] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
             }
             if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
             {
                 detail[i, 4] = "0";
             }
             else
             {
                 detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
             }
             if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
             {
                 detail[i, 5] = "0";
             }
             else
             {
                 detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
             }
             if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() == "")
             {
                 detail[i, 6] = "0";
             }
             else
             {
                 detail[i, 6] = gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString().Replace(".", "").Replace(",", ".");
             }
         }
         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ợ> <Mã hàng> <Số lượng> <Đơn giá> <Thành tiền> !", "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["Thành tiền"].SummaryText.Replace(".", "");
             if (active == "0")
             {
                 try
                 {
                     string ton = gen.GetString("select * from INOutwardFree where RefNo='" + txtsct.Text + "'");
                     themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid);
                     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 INOutwardFree(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,JournalMemo,Posted,StockID,TotalAmount,InvSeries,InvNo,InvDate,EmployeeID,No) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtldn.Text + "','False','" + dv + "','" + tong + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + txtnhd.EditValue.ToString() + "','" + userid + "','" + txtms.Text + "')");
                 string refid = gen.GetString("select * from INOutwardFree where RefNo='" + txtsct.Text + "'");
                 F.getrole(refid);
                 for (int i = 0; i < gridView1.RowCount - 1; i++)
                 {
                     gen.ExcuteNonquery("insert into INOutwardFreeDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,QuantityConvert) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "','" + detail[i, 6] + "')");
                 }
             }
             else
             {
                 gen.ExcuteNonquery("update INOutwardFree set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',JournalMemo=N'" + txtldn.Text + "',StockID='" + dv + "',TotalAmount='" + tong + "',Posted='False',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',InvDate='" + txtnhd.EditValue.ToString() + "',EmployeeID='" + userid + "',No='" + txtms.Text + "'  where RefID='" + role + "'");
                 gen.ExcuteNonquery("delete  from  INOutwardFreeDetail where RefID='" + role + "'");
                 for (int i = 0; i < gridView1.RowCount - 1; i++)
                 {
                     gen.ExcuteNonquery("insert into INOutwardFreeDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,QuantityConvert) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "','" + detail[i, 6] + "')");
                 }
             }
             F.myac();
             F.getactive("1");
             F.Text = "Xem phiếu xuất hàng khuyến mãi";
         }
     }
     catch
     {
         XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #22
0
        public void checkpck(string active, string role, Frm_hoadonxhgb F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, TextEdit txtsct, TextEdit txtname, TextEdit txtdc, TextEdit txtldn, DateEdit denct, DateEdit denht, string ngaychungtu,
                             ComboBoxEdit cbthue, string userid, string branchid, TextEdit txtms, TextEdit txtkhhd, TextEdit txtshd, TextEdit txtnhd, TextEdit txthtt, TextEdit txthttt, TextEdit txtthue, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, TextEdit txtquyen, LookUpEdit ledvx)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 8];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 0] = mh;
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        detail[i, 1] = "0";
                    }
                    else
                    {
                        detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString().Replace(".", "").Replace(",", ".");
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                    if (gridView1.GetRowCellValue(i, "Chi phí").ToString() == "")
                    {
                        detail[i, 6] = "0";
                    }
                    else
                    {
                        detail[i, 6] = gridView1.GetRowCellValue(i, "Chi phí").ToString().Replace(".", "");
                    }
                }

                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv       = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string dvx      = gen.GetString("select * from Stock where StockCode='" + ledvx.EditValue.ToString() + "'");
                    string tongtien = gridView1.Columns["Thành tiền"].SummaryText.Replace(".", "");
                    string chiphi   = gridView1.Columns["Chi phí"].SummaryText.Replace(".", "");
                    Double tongcong = Double.Parse(tongtien) + Double.Parse(chiphi);
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from SSInvoiceBranch where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);
                            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 SSInvoiceBranch(RefID,BranchID,RefType,PURefDate,PUPostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,PUJournalMemo,Posted,TotalAmount,Tax,InvSeries,InvNo,DueDateTime,TotalFreightAmount,UserID,CABARefDate,No,PayNo,TotalVatAmount,StockID,ParalellRefNo,AccountingObjectID1562) values(newid(),'" + branchid + "',101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtldn.Text + "','False','" + tongtien + "','" + cbthue.Text + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + txthtt.Text + "','" + chiphi + "','" + userid + "','" + txtnhd.EditValue.ToString() + "','" + txtms.Text + "',N'" + txthttt.Text + "','" + txtthue.Text.Replace(".", "") + "','" + dv + "','" + txtquyen.Text + "','" + dvx + "')");
                        string refid = gen.GetString("select * from SSInvoiceBranch where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','1368','51112','" + tongcong.ToString() + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','1368','33311','" + txtthue.Text.Replace(".", "") + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into SSInvoiceBranchDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,UnitPrice,Amount,FreightAmount) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 6] + "')");
                        }
                    }
                    else
                    {
                        gen.ExcuteNonquery("update SSInvoiceBranch set PURefDate='" + denct.EditValue.ToString() + "',PUPostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "', AccountingObjectAddress=N'" + txtdc.Text + "',PUJournalMemo=N'" + txtldn.Text + "',TotalAmount='" + tongtien + "',Tax='" + cbthue.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',DueDateTime=" + txthtt.Text + ",TotalFreightAmount='" + chiphi + "',UserID='" + userid + "',CABARefDate='" + txtnhd.EditValue.ToString() + "',No='" + txtms.Text + "',PayNo=N'" + txthttt.Text + "',TotalVatAmount='" + txtthue.Text.Replace(".", "") + "',StockID='" + dv + "',ParalellRefNo='" + txtquyen.Text + "',AccountingObjectID1562='" + dvx + "' where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  SSInvoiceBranchDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','1368','51112','" + tongcong.ToString() + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','1368','33311','" + txtthue.Text.Replace(".", "") + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into SSInvoiceBranchDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,UnitPrice,Amount,FreightAmount) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 6] + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu hóa đơn xuất hàng gửi bán";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #23
0
        //save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void checkpxht(string active, string role, Frm_phieudieuchinh F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, TextEdit txtsct, TextEdit txtname,
                              TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                              ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtshd, TextEdit txtkhhd, TextEdit txtnhd, string userid, string branchid, TextEdit txtms, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, Boolean noibo, TextEdit txtthuesuat, CheckEdit cghd)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                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();
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 2] = mh;
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        detail[i, 3] = "0";
                    }
                    else
                    {
                        detail[i, 3] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    }
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        detail[i, 4] = "0";
                    }
                    else
                    {
                        detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        detail[i, 5] = "0";
                    }
                    else
                    {
                        detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() == "")
                    {
                        detail[i, 6] = "0";
                    }
                    else
                    {
                        detail[i, 6] = gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString().Replace(".", "").Replace(",", ".");
                    }

                    detail[i, 7] = gridView1.GetRowCellValue(i, "Mã ngành").ToString();
                    detail[i, 8] = gridView1.GetRowCellValue(i, "Nhóm chi phí").ToString();

                    detail[i, 9]  = gridView1.GetRowCellValue(i, "Ca").ToString();
                    detail[i, 10] = gridView1.GetRowCellValue(i, "Tài xế").ToString();
                    detail[i, 11] = gridView1.GetRowCellValue(i, "Số xe").ToString();

                    if (gridView1.GetRowCellValue(i, "Số KM").ToString() == "")
                    {
                        detail[i, 12] = "0";
                    }
                    else
                    {
                        detail[i, 12] = gridView1.GetRowCellValue(i, "Số KM").ToString().Replace(".", "").Replace(",", ".");
                    }
                }
                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ợ> <Mã hàng> <Số lượng> <Đơn giá> <Thành tiền> !", "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["Thành tiền"].SummaryText.Replace(".", "");
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from OUTdeficit where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau, noibo);
                            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 OUTdeficit(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,JournalMemo,Posted,StockID,TotalAmount,InvSeries,InvNo,InvDate,EmployeeID,No,Cancel,Tax,IsExport) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtldn.Text + "','False','" + dv + "','" + tong + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + txtnhd.EditValue.ToString() + "','" + userid + "','" + txtms.Text + "','" + noibo + "','" + txtthuesuat.EditValue + "','" + cghd.Checked + "')");
                        string refid = gen.GetString("select * from OUTdeficit where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into OUTdeficitDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,QuantityConvert,Description,CustomField5,Ca,Taixe,Soxe,Sokm) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "','" + detail[i, 6] + "','" + detail[i, 7] + "','" + detail[i, 8] + "',N'" + detail[i, 9] + "',N'" + detail[i, 10] + "','" + detail[i, 11] + "','" + detail[i, 12] + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,Occupation,GroupCost) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + detail[i, 7] + "','" + detail[i, 8] + "')");
                        }
                    }
                    else
                    {
                        gen.ExcuteNonquery("update OUTdeficit set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',JournalMemo=N'" + txtldn.Text + "',StockID='" + dv + "',TotalAmount='" + tong + "',Posted='False',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',InvDate='" + txtnhd.EditValue.ToString() + "',EmployeeID='" + userid + "',No='" + txtms.Text + "', Cancel='" + noibo + "', Tax='" + txtthuesuat.EditValue + "',IsExport='" + cghd.Checked + "'  where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  OUTdeficitDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into OUTdeficitDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,UnitPrice,QuantityConvert,Description,CustomField5,Ca,Taixe,Soxe,Sokm) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "','" + detail[i, 6] + "','" + detail[i, 7] + "','" + detail[i, 8] + "',N'" + detail[i, 9] + "',N'" + detail[i, 10] + "','" + detail[i, 11] + "','" + detail[i, 12] + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,Occupation,GroupCost) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + detail[i, 7] + "','" + detail[i, 8] + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu xuất hàng thừa";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #24
0
        public void checkpnk(string active, string role, Frm_phieunhapvo F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                             TextEdit txtngh, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripSplitButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtmst, TextEdit txtptvc, string userid, string branchid, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, CheckEdit chtc, TextEdit txttaixe)
        {
            /*try
             * {*/
            string dtt   = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
            string dt    = gen.GetString("select * from hamaco.dbo.AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
            string dt_ta = gen.GetString("select * from hamaco_ta.dbo.AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
            string dt_tn = gen.GetString("select * from hamaco_tn.dbo.AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");

            string[,] detail = new string[20, 15];
            Double[,] tong   = new Double[20, 20];
            for (int j = 0; j < 3; j++)
            {
                tong[j, 0] = 0;
                tong[j, 1] = 0;
                tong[j, 2] = 0;
            }
            string check = "0";

            for (int i = 0; i < gridView1.RowCount - 1; i++)
            {
                if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                {
                    check = "1";
                }
                else
                {
                    detail[i, 0] = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                }


                if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                {
                    detail[i, 1] = "0";
                    detail[i, 2] = "0";
                }
                else
                {
                    detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                }

                if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                {
                    detail[i, 4] = "0";
                }
                else
                {
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                }
                if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                {
                    detail[i, 5] = "0";
                }
                else
                {
                    detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                }

                if (gridView1.GetRowCellValue(i, "Số lượng xuất").ToString() == "")
                {
                    detail[i, 8] = "0";
                }
                else
                {
                    detail[i, 8] = gridView1.GetRowCellValue(i, "Số lượng xuất").ToString().Replace(".", "");
                }

                if (gridView1.GetRowCellValue(i, "Chênh lệch").ToString() == "")
                {
                    detail[i, 9] = "0";
                }
                else
                {
                    detail[i, 9] = gridView1.GetRowCellValue(i, "Chênh lệch").ToString().Replace(".", "");
                }

                if (gridView1.GetRowCellValue(i, "Thế chân").ToString() == "")
                {
                    detail[i, 11] = "0";
                }
                else
                {
                    detail[i, 11] = gridView1.GetRowCellValue(i, "Thế chân").ToString().Replace(".", "");
                }


                if (gridView1.GetRowCellValue(i, "Đơn giá BX").ToString() == "")
                {
                    detail[i, 12] = "0";
                }
                else
                {
                    detail[i, 12] = gridView1.GetRowCellValue(i, "Đơn giá BX").ToString().Replace(".", "").Replace(",", ".");
                }
                if (gridView1.GetRowCellValue(i, "Bốc xếp").ToString() == "")
                {
                    detail[i, 13] = "0";
                }
                else
                {
                    detail[i, 13] = gridView1.GetRowCellValue(i, "Bốc xếp").ToString().Replace(".", "").Replace(",", ".");
                }


                if (cbldt.EditValue.ToString() == "Khách hàng")
                {
                    if (Double.Parse(detail[i, 9]) > 0)
                    {
                        detail[i, 7] = "131";
                        detail[i, 6] = "34411";
                    }
                    else if (Double.Parse(detail[i, 9]) < 0)
                    {
                        detail[i, 6] = "131";
                        detail[i, 7] = "34411";
                    }
                }
                else
                {
                    if (Double.Parse(detail[i, 9]) < 0)
                    {
                        detail[i, 6] = "331";
                        detail[i, 7] = "24411";
                    }
                }


                detail[i, 3] = gridView1.GetRowCellValue(i, "Diễn giải").ToString();

                if (detail[i, 3] == "HAMACO")
                {
                    detail[i, 10] = gen.GetString("select * from hamaco.dbo.InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                    tong[0, 0]    = tong[0, 0] + Double.Parse(detail[i, 5]);
                }
                else if (detail[i, 3] == "Thiên An")
                {
                    detail[i, 10] = gen.GetString("select * from hamaco_ta.dbo.InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                    tong[1, 0]    = tong[1, 0] + Double.Parse(detail[i, 5]);
                }
                else if (detail[i, 3] == "Dịch vụ HAMACO")
                {
                    detail[i, 10] = gen.GetString("select * from hamaco_tn.dbo.InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                    tong[2, 0]    = tong[2, 0] + Double.Parse(detail[i, 5]);
                }
            }
            if (check == "1")
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                string dv = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                string ldt;
                if (cbldt.EditValue.ToString() == "Khách hàng")
                {
                    ldt = "0";
                }
                else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                {
                    ldt = "1";
                }
                else
                {
                    ldt = "2";
                }
                string tongtien = gridView1.Columns["Thành tiền"].SummaryText.Replace(".", "");
                if (active == "0")
                {
                    /*try
                     * {
                     *  string ton = gen.GetString("select * from INInwardLPG where RefNo='" + txtsct.Text + "'");
                     *  themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);
                     *  //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 { }*/

                    themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);

                    gen.ExcuteNonquery("insert into INInwardLPG(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,TotalAmount,UserID,InwardType,CustomField2) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dtt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "',N'" + txtptvc.Text + "','" + tongtien + "','" + userid + "','" + chtc.Checked + "',N'" + txttaixe.Text + "')");
                    gen.ExcuteNonquery("insert into hamaco.dbo.INInwardSU(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,TotalAmount,UserID,InwardType,CustomField2) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "',N'" + txtptvc.Text + "','" + tong[0, 0] + "','" + userid + "','" + chtc.Checked + "',N'" + txttaixe.Text + "')");
                    gen.ExcuteNonquery("insert into hamaco_ta.dbo.INInwardSU(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,TotalAmount,UserID,InwardType,CustomField2) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt_ta + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "',N'" + txtptvc.Text + "','" + tong[1, 0] + "','" + userid + "','" + chtc.Checked + "',N'" + txttaixe.Text + "')");
                    gen.ExcuteNonquery("insert into hamaco_tn.dbo.INInwardSU(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,TotalAmount,UserID,InwardType,CustomField2) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt_tn + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "',N'" + txtptvc.Text + "','" + tong[2, 0] + "','" + userid + "','" + chtc.Checked + "',N'" + txttaixe.Text + "')");

                    string refid = gen.GetString("select * from INInwardLPG where RefNo='" + txtsct.Text + "'");
                    F.getrole(refid);

                    for (int i = 0; i < gridView1.RowCount - 1; i++)
                    {
                        gen.ExcuteNonquery("insert into INInwardLPGDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPrice,Amount,DebitAccount,CreditAccount,ListItemID,ConvertRate,UnitPriceConvertOC,AmountOC) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 8] + "','" + detail[i, 9] + "','" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 7] + "','" + detail[i, 6] + "','" + detail[i, 10] + "','" + detail[i, 11] + "','" + detail[i, 12] + "','" + detail[i, 13] + "')");
                    }
                }
                else
                {
                    gen.ExcuteNonquery("update INInwardLPG set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dtt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo=N'" + txtptvc.Text + "',TotalAmount='" + tongtien + "',UserID='" + userid + "', InwardType='" + chtc.Checked + "',CustomField2=N'" + txttaixe.Text + "'  where RefID = '" + role + "'");
                    gen.ExcuteNonquery("update hamaco.dbo.INInwardSU set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo=N'" + txtptvc.Text + "',TotalAmount='" + tong[0, 0] + "',UserID='" + userid + "', InwardType='" + chtc.Checked + "',CustomField2=N'" + txttaixe.Text + "'  where RefNo = '" + txtsct.Text + "'");
                    gen.ExcuteNonquery("update hamaco_ta.dbo.INInwardSU set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt_ta + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo=N'" + txtptvc.Text + "',TotalAmount='" + tong[1, 0] + "',UserID='" + userid + "', InwardType='" + chtc.Checked + "',CustomField2=N'" + txttaixe.Text + "'  where RefNo = '" + txtsct.Text + "'");
                    gen.ExcuteNonquery("update hamaco_tn.dbo.INInwardSU set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt_tn + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo=N'" + txtptvc.Text + "',TotalAmount='" + tong[2, 0] + "',UserID='" + userid + "', InwardType='" + chtc.Checked + "',CustomField2=N'" + txttaixe.Text + "'  where RefNo = '" + txtsct.Text + "'");

                    gen.ExcuteNonquery("delete  from  INInwardLPGDetail where RefID ='" + role + "'");
                    for (int i = 0; i < gridView1.RowCount - 1; i++)
                    {
                        gen.ExcuteNonquery("insert into INInwardLPGDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPrice,Amount,DebitAccount,CreditAccount,ListItemID,ConvertRate,UnitPriceConvertOC,AmountOC) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 8] + "','" + detail[i, 9] + "','" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 7] + "','" + detail[i, 6] + "','" + detail[i, 10] + "','" + detail[i, 11] + "','" + detail[i, 12] + "','" + detail[i, 13] + "')");
                    }
                }
                gen.ExcuteNonquery("dondathangvolpg '" + txtsct.Text + "'");
                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);
             * }*/
        }
Exemple #25
0
        public void checkpxk(string active, string role, Frm_phieunhapgas F, GridView gridView1, GridView gridView2, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                             TextEdit txtngh, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripSplitButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtmst, TextEdit txtptvc, string userid, string branchid, TextEdit txtpnv, ComboBoxEdit cbthue, LookUpEdit lenv, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail  = new string[20, 8];
                string[,] detail1 = new string[20, 8];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 0] = mh;
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        detail[i, 1] = "0";
                    }
                    else
                    {
                        detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString().Replace(".", "").Replace(",", ".");
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                    detail[i, 6] = gridView1.GetRowCellValue(i, "Chi phí").ToString().Replace(".", "");
                    if (gridView1.GetRowCellValue(i, "Chiết khấu").ToString() == "")
                    {
                        detail[i, 3] = "0";
                    }
                    else
                    {
                        detail[i, 3] = gridView1.GetRowCellValue(i, "Chiết khấu").ToString();
                    }
                    if (gridView1.GetRowCellValue(i, "Tiền CK").ToString() == "")
                    {
                        detail[i, 7] = "0";
                    }
                    else
                    {
                        detail[i, 7] = gridView1.GetRowCellValue(i, "Tiền CK").ToString();
                    }
                }


                for (int i = 0; i < gridView2.RowCount; i++)
                {
                    if (gridView2.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView2.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail1[i, 0] = mh;
                    }
                    if (gridView2.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        check = "1";
                    }
                    detail1[i, 1] = gridView2.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    detail1[i, 2] = gridView2.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    detail1[i, 3] = gridView2.GetRowCellValue(i, "Diễn giải").ToString();

                    if (gridView2.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        check = "1";
                    }
                    detail1[i, 4] = gridView2.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "");
                    if (gridView2.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail1[i, 5] = gridView2.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                }

                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string ldt;
                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }
                    string tongtien = gridView2.Columns["Thành tiền"].SummaryText.Replace(".", "");

                    string tongthanhtien = gridView1.Columns["Thành tiền"].SummaryText;
                    string tongchiphi    = gridView1.Columns["Tiền CK"].SummaryText;
                    tongthanhtien = tongthanhtien.Replace(".", "");
                    tongchiphi    = tongchiphi.Replace(".", "");

                    string nv = "";
                    try
                    {
                        nv = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + lenv.EditValue.ToString() + "'");
                    }
                    catch { }

                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from INOutward where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, txtpnv, tsbttruoc, tsbtsau);
                            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 { }
                        try
                        {
                            string ton = gen.GetString("select * from INOutwardSU where RefNo='" + txtpnv.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, txtpnv, tsbttruoc, tsbtsau);
                            XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtpnv.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch { }

                        try
                        {
                            gen.ExcuteNonquery("insert into INOutward(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,Tax,EmployeeID,EmployeeIDSA,TotalFreightAmount,TotalAmount) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + txtptvc.Text + "','" + cbthue.Text + "','" + userid + "','" + nv + "','" + tongchiphi + "','" + tongthanhtien + "')");
                        }
                        catch
                        {
                            gen.ExcuteNonquery("insert into INOutward(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,Tax,EmployeeID,TotalFreightAmount,TotalAmount) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + txtptvc.Text + "','" + cbthue.Text + "','" + userid + "','" + tongchiphi + "','" + tongthanhtien + "')");
                        }
                        string refid = gen.GetString("select * from INOutward where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INOutwardDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,DiscountRate,UnitPrice,Amount,QuantityExits,QuantityConvertExits,Cost,DiscountAmount) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 4] + "','" + detail[i, 5] + "',0,0,'" + detail[i, 6] + "','" + detail[i, 7] + "')");
                        }

                        gen.ExcuteNonquery("insert into INOutwardSU(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,ShippingNo,TotalAmount,UserID) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtpnv.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + txtptvc.Text + "','" + tongtien + "','" + userid + "')");
                        string id = gen.GetString("select * from INOutwardSU where RefNo='" + txtpnv.Text + "'");
                        gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + id + "','" + txtsct.Text + "','1313','1563','" + tongtien + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        gen.ExcuteNonquery("update INOutward set refSUID='" + id + "' where refID='" + refid + "' ");
                        for (int i = 0; i < gridView2.RowCount; i++)
                        {
                            gen.ExcuteNonquery("insert into INOutwardSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPrice,Amount,DebitAccount,CreditAccount) values(newid(),'" + id + "','" + detail1[i, 1] + "','" + detail1[i, 2] + "'," + i + ",'" + detail1[i, 0] + "',N'" + detail1[i, 3] + "',0,0,'" + detail1[i, 4] + "','" + detail1[i, 5] + "','1313','1563')");
                        }
                    }
                    else
                    {
                        try
                        {
                            gen.ExcuteNonquery("update INOutward set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo='" + txtptvc.Text + "',Tax='" + cbthue.Text + "',EmployeeID='" + userid + "',EmployeeIDSA='" + nv + "',TotalFreightAmount='" + tongchiphi + "',TotalAmount='" + tongthanhtien + "'  where RefID='" + role + "'");
                        }
                        catch
                        {
                            gen.ExcuteNonquery("update INOutward set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo='" + txtptvc.Text + "',Tax='" + cbthue.Text + "',EmployeeID='" + userid + "',EmployeeIDSA = Null,TotalFreightAmount='" + tongchiphi + "',TotalAmount='" + tongthanhtien + "'  where RefID='" + role + "'");
                        }
                        gen.ExcuteNonquery("delete  from  INOutwardDetail where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INOutwardDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,DiscountRate,UnitPrice,Amount,QuantityExits,QuantityConvertExits,Cost,DiscountAmount) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 4] + "','" + detail[i, 5] + "',0,0,'" + detail[i, 6] + "','" + detail[i, 7] + "')");
                        }

                        string id = gen.GetString("select refSUID from INOutward where refID='" + role + "'");
                        gen.ExcuteNonquery("update INOutwardSU set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',Posted='False',ShippingNo='" + txtptvc.Text + "',TotalAmount='" + tongtien + "',UserID='" + userid + "'  where RefID = '" + id + "'");
                        gen.ExcuteNonquery("delete  from  INOutwardSUDetail where RefID ='" + id + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + id + "'");
                        gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + id + "','" + txtsct.Text + "','1313','1563','" + tongtien + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        for (int i = 0; i < gridView2.RowCount; i++)
                        {
                            gen.ExcuteNonquery("insert into INOutwardSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,QuantityExits,QuantityConvertExits,UnitPrice,Amount,DebitAccount,CreditAccount) values(newid(),'" + id + "','" + detail1[i, 1] + "','" + detail1[i, 2] + "'," + i + ",'" + detail1[i, 0] + "',N'" + detail1[i, 3] + "',0,0,'" + detail1[i, 4] + "','" + detail1[i, 5] + "','1313','1563')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu nhập kho Gas";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #26
0
        public void checkpxk(string active, string role, Frm_ddhncc F, GridView gridView1, SearchLookUpEdit ledt, LookUpEdit ledv, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                             TextEdit txtngh, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripSplitButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtmst, TextEdit txtptvc, string userid, string branchid, ComboBoxEdit cbthue, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, TextEdit txttthue, TextEdit txtptgh, RadioGroup tracham, RadioGroup hangnhap, TextEdit ghichu, TextEdit hanno, CheckEdit duyet, TextEdit txtcmnd, SearchLookUpEdit lehg, string lbduyet)
        {
            try
            {
                string dt = gen.GetString("select AccountingObjectID from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");

                string[,] detail = new string[100, 20];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select InventoryItemID from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 0] = mh;
                    }

                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        detail[i, 1] = "0";
                    }
                    else
                    {
                        detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Trọng lượng").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Trọng lượng").ToString().Replace(".", "").Replace(",", ".");

                    if (gridView1.GetRowCellValue(i, "Bó").ToString() == "")
                    {
                        detail[i, 3] = "0";
                    }
                    else
                    {
                        detail[i, 3] = gridView1.GetRowCellValue(i, "Bó").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");

                    if (gridView1.GetRowCellValue(i, "CK sản lượng").ToString() == "")
                    {
                        detail[i, 5] = "0";
                    }
                    else
                    {
                        detail[i, 5] = gridView1.GetRowCellValue(i, "CK sản lượng").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 6] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");

                    if (gridView1.GetRowCellValue(i, "CK thanh toán").ToString() == "")
                    {
                        detail[i, 7] = "0";
                    }
                    else
                    {
                        detail[i, 7] = gridView1.GetRowCellValue(i, "CK thanh toán").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "CK trực tiếp").ToString() == "")
                    {
                        detail[i, 8] = "0";
                    }
                    else
                    {
                        detail[i, 8] = gridView1.GetRowCellValue(i, "CK trực tiếp").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "CK ngắn hạn").ToString() == "")
                    {
                        detail[i, 9] = "0";
                    }
                    else
                    {
                        detail[i, 9] = gridView1.GetRowCellValue(i, "CK ngắn hạn").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "CK vùng").ToString() == "")
                    {
                        detail[i, 10] = "0";
                    }
                    else
                    {
                        detail[i, 10] = gridView1.GetRowCellValue(i, "CK vùng").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Hỗ trợ CT").ToString() == "")
                    {
                        detail[i, 11] = "0";
                    }
                    else
                    {
                        detail[i, 11] = gridView1.GetRowCellValue(i, "Hỗ trợ CT").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Hỗ trợ VC").ToString() == "")
                    {
                        detail[i, 12] = "0";
                    }
                    else
                    {
                        detail[i, 12] = gridView1.GetRowCellValue(i, "Hỗ trợ VC").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "CK khác").ToString() == "")
                    {
                        detail[i, 13] = "0";
                    }
                    else
                    {
                        detail[i, 13] = gridView1.GetRowCellValue(i, "CK khác").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Số lượng đặt").ToString() == "")
                    {
                        detail[i, 14] = "0";
                    }
                    else
                    {
                        detail[i, 14] = gridView1.GetRowCellValue(i, "Số lượng đặt").ToString().Replace(".", "").Replace(",", ".");
                    }

                    if (gridView1.GetRowCellValue(i, "Trọng lượng đặt").ToString() == "")
                    {
                        detail[i, 15] = "0";
                    }
                    else
                    {
                        detail[i, 15] = gridView1.GetRowCellValue(i, "Trọng lượng đặt").ToString().Replace(".", "").Replace(",", ".");
                    }
                }

                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    F.getloi("1");
                    return;
                }
                else
                {
                    string dv = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");

                    string tongthanhtien = Math.Round(Double.Parse(gridView1.Columns["Thành tiền"].SummaryText)).ToString().Replace(".", "");
                    string thue          = txttthue.EditValue.ToString().Replace(".", "");

                    string nguoiduyet = null;
                    if (duyet.Checked == true && lbduyet == "")
                    {
                        nguoiduyet = gen.GetString("select FullName from MSC_User where UserID='" + userid + "'");
                    }
                    else if (duyet.Checked == true && lbduyet != "")
                    {
                        nguoiduyet = lbduyet;
                    }

                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from DDHNCC where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau);
                            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 DDHNCC(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,ShippingNo,CustomField9,EmployeeID,TotalAmount,TotalAmountOC,Cancel,CustomField6,CustomField1,ExchangeRate,IsImportPurchase,CustomField2,CustomField3) values(newid(),'" + hangnhap.SelectedIndex + "','" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "',N'" + txtptvc.Text + "','" + cbthue.Text + "','" + userid + "','" + tongthanhtien + "','" + thue + "','" + tracham.SelectedIndex + "',N'" + txtptgh.Text + "',N'" + ghichu.Text + "'," + hanno.EditValue.ToString() + ",'" + duyet.Checked + "',N'" + nguoiduyet + "','" + txtcmnd.Text + "')");

                        string refid = gen.GetString("select * from DDHNCC where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into DDHNCCDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,ConvertRate,InventoryItemID,UnitPriceConvert,UnitPrice,Amount,CustomField1,CustomField2,CustomField3,CustomField4,CustomField5,QuantityExits,QuantityConvertExits,UnitPriceOC,UnitPriceConvertOC) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 3] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 4] + "','" + detail[i, 6] + "','" + detail[i, 7] + "','" + detail[i, 8] + "','" + detail[i, 9] + "','" + detail[i, 10] + "','" + detail[i, 11] + "','" + detail[i, 12] + "','" + detail[i, 13] + "','" + detail[i, 14] + "','" + detail[i, 15] + "')");
                        }
                    }
                    else
                    {
                        gen.ExcuteNonquery("update DDHNCC set RefType='" + hangnhap.SelectedIndex + "',RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress=N'" + txtdc.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',Posted='False',ShippingNo=N'" + txtptvc.Text + "',CustomField9='" + cbthue.Text + "',TotalAmount='" + tongthanhtien + "',TotalAmountOC='" + thue + "',Cancel='" + tracham.SelectedIndex + "',CustomField6=N'" + txtptgh.Text + "',CustomField1=N'" + ghichu.Text + "',ExchangeRate=" + hanno.EditValue.ToString() + ",IsImportPurchase='" + duyet.Checked + "',CustomField2=N'" + nguoiduyet + "',CustomField3='" + txtcmnd.Text + "' where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  DDHNCCDetail where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into DDHNCCDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,ConvertRate,InventoryItemID,UnitPriceConvert,UnitPrice,Amount,CustomField1,CustomField2,CustomField3,CustomField4,CustomField5,QuantityExits,QuantityConvertExits,UnitPriceOC,UnitPriceConvertOC) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 3] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 4] + "','" + detail[i, 6] + "','" + detail[i, 7] + "','" + detail[i, 8] + "','" + detail[i, 9] + "','" + detail[i, 10] + "','" + detail[i, 11] + "','" + detail[i, 12] + "','" + detail[i, 13] + "','" + detail[i, 14] + "','" + detail[i, 15] + "')");
                        }
                    }
                    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);
            }
        }