示例#1
0
        public void tsbtpxht(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang, Boolean noibo)
        {
            try
            {
                Frm_phieudieuchinh u = new Frm_phieudieuchinh();
                if (noibo == false)
                {
                    u.myac = new Frm_phieudieuchinh.ac(F.refreshpxht);
                }
                else
                {
                    u.myac = new Frm_phieudieuchinh.ac(F.refreshpxhtnb);
                }
                u.getactive(a);
                u.getpt("pxht");
                u.getsub(subsys);
                u.getkhach(khach);
                u.gethang(hang);
                u.getroleid(roleid);
                u.getbranch(branchid);
                u.getnoibo(noibo);
                u.getuser(userid);
                u.getdate(ngaychungtu);

                if (a == "1")
                {
                    u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString());
                }
                else
                {
                    try
                    {
                        u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString());
                    }
                    catch
                    {
                        u.getrole(gen.GetString("select Top 1 StockCode from Stock where StockID in (select StockID from MSC_UserJoinStock where UserID='" + userid + "') order by StockCode"));
                    }
                }

                u.ShowDialog();
            }
            catch { MessageBox.Show("Vui lòng chọn phiếu nhập hàng thừa trước khi sửa."); }
        }
示例#2
0
 public void tsbtpnhtchuyen(string a, string ma, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang)
 {
     try
     {
         Frm_phieudieuchinh u = new Frm_phieudieuchinh();
         u.getactive(a);
         u.getsub(subsys);
         u.gethang(hang);
         u.getkhach(khach);
         u.getroleid(roleid);
         u.getpt("pnht");
         u.getbranch(branchid);
         u.getuser(userid);
         u.getdate(ngaychungtu);
         u.getphieu(ma);
         u.ShowDialog();
     }
     catch { MessageBox.Show("Vui lòng chọn phiếu nhập hàng thừa trước khi sửa."); }
 }
示例#3
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);
     }
 }
示例#4
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);
            }
        }