示例#1
0
        public void tsbtpnk(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang, string tsbt)
        {
            try
            {
                Frm_phieunhapkho u = new Frm_phieunhapkho();
                if (tsbt == "tsbtpxkhg")
                {
                    u.myac = new Frm_phieunhapkho.ac(F.refreshpxkhgkh);
                }
                else
                {
                    u.myac = new Frm_phieunhapkho.ac(F.refreshpnktt);
                }
                u.getactive(a);
                u.getroleid(roleid);
                u.getsub(subsys);
                u.getpt(tsbt);
                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."); }
        }
示例#2
0
 public void checksauxkhg(string sct, int vt, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, Frm_phieunhapkho F, string ngay, string mk)
 {
     try
     {
         string idkho = gen.GetString("select * from Stock where StockCode='" + mk + "'");
         tsbttruoc.Enabled = true;
         string id;
         if (vt == 0)
         {
             id = gen.GetString("select Top 1 * from INInwardTT where RefNo > '" + sct + "' and Month(RefDate)='" + DateTime.Parse(ngay).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngay).Year.ToString() + "' and StockID='" + idkho + "'  and RefType='3'  order by RefNo ASC");
         }
         else
         {
             id = gen.GetString("select Top 1 * from INInwardTT where RefNo > '" + sct + "' and Month(RefDate)='" + DateTime.Parse(ngay).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngay).Year.ToString() + "' and StockID='" + idkho + "'  and RefType='3' order by RefNo DESC");
             tsbtsau.Enabled = false;
         }
         F.getrole(id);
     }
     catch
     {
         tsbtsau.Enabled = false;
     }
 }
示例#3
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);
            }
        }