예제 #1
0
 public void tsbtddhnccchuyen(string a, string sochungtu, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang, string phuongtien, string taixe, string cmnd)
 {
     try
     {
         Frm_ddhncc u = new Frm_ddhncc();
         u.getactive(a);
         u.getroleid(roleid);
         u.getphuongtien(phuongtien);
         u.getsub(subsys);
         u.getpt("ddhncc");
         u.getdate(ngaychungtu);
         u.getuser(userid);
         u.getbranch(branchid);
         u.getkhach(khach);
         u.getphieu(sochungtu);
         u.gethang(hang);
         u.gettaixe(taixe);
         u.getcmnd(cmnd);
         u.ShowDialog();
     }
     catch { MessageBox.Show("Vui lòng chọn phiếu nhập kho trước khi sửa."); }
 }
예제 #2
0
        public void tsbtddhncc(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang)
        {
            try
            {
                Frm_ddhncc u = new Frm_ddhncc();
                u.myac = new Frm_ddhncc.ac(F.refreshddhncc);
                u.getactive(a);
                u.getroleid(roleid);
                u.getsub(subsys);
                u.getpt("ddhncc");
                u.getdate(ngaychungtu);
                u.getuser(userid);
                u.getbranch(branchid);
                u.getkhach(khach);
                u.gethang(hang);

                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 kho trước khi sửa."); }
        }
예제 #3
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);
            }
        }