Esempio n. 1
0
        public bool DeleteDetail(PLTransaction plTrans, DOFWObjRelData Data,long ky_id)
        {
            if (Data == null) return true;

            DatabaseFB db = plTrans.db;
            DbTransaction dbTrans = plTrans.dbTrans;
            try
            {
                if (!KhoTonKhoHelp.Check_PLQ(plTrans,ky_id,
                    Data.DES_ID, Data.DES_TYPE))
                {
                    string sql = "delete from kho_ton_kho_" +
                          ky_id +
                            " where des_id=@des_id and des_type=@des_type and hh_id=@hh_id and tinh_trang_hh=@tinh_trang_hh";
                    DbCommand cmd_Delete = db.GetSQLStringCommand(sql);
                    db.AddInParameter(cmd_Delete, "@des_id", DbType.Int64, Data.DES_ID);
                    db.AddInParameter(cmd_Delete, "@des_type", DbType.Int64, Data.DES_TYPE);
                    db.AddInParameter(cmd_Delete, "@hh_id", DbType.Int64, Data.HH_ID);
                    db.AddInParameter(cmd_Delete, "@tinh_trang_hh", DbType.Int64, Data.TINH_TRANG_HH);

                    db.ExecuteNonQuery(cmd_Delete, dbTrans);
                    //Cập nhật tồn kho từ kỳ hiện tại trở về sau
                    KhoTonKhoHelp.CapNhatNhapXuatChuyen(plTrans, Data, 3,ky_id);
                }
            }
            catch
            {
                return false;
            }
            return true;
        }
Esempio n. 2
0
 /// <summary>
 /// Cập nhật hàng tồn kho khi Insert/Update/Delete phiếu Nhập/Xuất/Chuyển        
 /// </summary>
 /// <param name="plTrans">Đối tượng Transaction</param>       
 /// <param name="Data">Đối tượng DOFWObjRelData</param>
 /// <param name="IUD">Insert/Update/Delete(1/2/3)</param>
 public static void CapNhatNhapXuatChuyen(PLTransaction plTrans, DOFWObjRelData Data, int IUD,long ky_id)
 {
     if (Data.INOUT1 == "IN" && Data.INOUT2 == "")
     {
         KhoTonKhoHelp.CapNhatNhapXuatHangTon(plTrans,ky_id,
             true, Data.HH_ID, Data.KHO_ID1, Data.TINH_TRANG_HH, Data.SO_LG, Data.TONG_TR_LG, IUD);
         if (IUD != 3)
         {
             KhoTonKhoHelp.UpdateGhiChu(plTrans, ky_id,
                 Data.HH_ID, Data.KHO_ID1, Data.TINH_TRANG_HH, Data.GHI_CHU);
         }
     }
     else if (Data.INOUT1 == "OUT" && Data.INOUT2 == "")
     {
         KhoTonKhoHelp.CapNhatNhapXuatHangTon(plTrans, ky_id,
             false, Data.HH_ID, Data.KHO_ID1, Data.TINH_TRANG_HH, Data.SO_LG, Data.TONG_TR_LG, IUD);
     }
     else
     {
         KhoTonKhoHelp.CapNhatChuyenKhoHangTon(plTrans, ky_id,
             Data.HH_ID, Data.TINH_TRANG_HH, Data.SO_LG, Data.TONG_TR_LG, Data.KHO_ID1, Data.KHO_ID2, IUD);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Lấy dữ liệu gốc từ DB
 /// </summary>
 /// <param name="plTrans">Đối tượng PLTransaction</param>        
 /// <param name="DOX">Đối tượng DOPhieuX</param>
 /// <returns>Danh sách các đối tượng DOFWObjRelData</returns>
 public static List<DOFWObjRelData> GetDataDesDB(PLTransaction plTrans, DOPhieuX DOX,long ky_id)
 {
     List<DOFWObjRelData> listObjRel = new List<DOFWObjRelData>();
     try
     {
         ITonKho data = (ITonKho)DOX;
         //long ky_id = KhoTonKhoHelp.GetKy(plTrans, data.GetNgayPhatSinh());
         DataSet ds = plTrans.LoadDataSet("kho_ton_kho_" + ky_id, "DES_ID", DOX.GetID());
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             DOFWObjRelData ObjRel = new DOFWObjRelData();
             ObjRel.ID_TEM = HelpNumber.ParseInt64(dr["ID_TEM"]);
             ObjRel.SRC_ID = HelpNumber.ParseInt64(dr["SRC_ID"]);
             ObjRel.SRC_TYPE = HelpNumber.ParseInt64(dr["SRC_TYPE"]);
             ObjRel.DES_ID = HelpNumber.ParseInt64(dr["DES_ID"]);
             ObjRel.DES_TYPE = HelpNumber.ParseInt64(dr["DES_TYPE"]);
             ObjRel.HH_ID = HelpNumber.ParseInt64(dr["HH_ID"]);
             ObjRel.SO_LG = HelpNumber.ParseDecimal(dr["SO_LG"]);
             ObjRel.TONG_TR_LG = HelpNumber.ParseDecimal(dr["TONG_TR_LG"]);
             ObjRel.NGUOI_CAP_NHAT = HelpNumber.ParseInt64(dr["NGUOI_CAP_NHAT"]);
             ObjRel.NGAY_CAP_NHAT = (DateTime?)DateTime.Parse(dr["NGAY_CAP_NHAT"].ToString());
             ObjRel.NGUOI_PHAT_SINH = HelpNumber.ParseInt64(dr["NGUOI_PHAT_SINH"]);
             ObjRel.NGAY_PHAT_SINH = (DateTime?)DateTime.Parse(dr["NGAY_PHAT_SINH"].ToString());
             ObjRel.INOUT1 = dr["INOUT1"].ToString();
             ObjRel.KHO_ID1 = HelpNumber.ParseInt64(dr["KHO_ID1"]);
             ObjRel.INOUT2 = dr["INOUT2"].ToString();
             ObjRel.KHO_ID2 = HelpNumber.ParseInt64(dr["KHO_ID2"]);
             ObjRel.DON_VI_TINH = HelpNumber.ParseInt64(dr["DON_VI_TINH"]);
             ObjRel.GIA = HelpNumber.ParseDecimal(dr["GIA"]);
             ObjRel.TINH_TRANG_HH = HelpNumber.ParseInt64(dr["TINH_TRANG_HH"]);
             listObjRel.Add(ObjRel);
         }
         return listObjRel;
     }
     catch (Exception ex)
     {
         plTrans.Rollback();
         PLException.AddException(ex);
         return listObjRel;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Lấy dữ liệu chuẩn bị cho việc lưu DB
        /// </summary>
        /// <param name="Src">Loại phiếu Src</param>
        /// <param name="SrcID">ID phiếu Src</param>
        /// <param name="DOX">Đối tượng DOPhieuX</param>
        /// <returns>Danh sách các đối tượng DOFWObjRelData</returns>
        public static List<DOFWObjRelData> GetData(PLTransaction plTrans, long Src, long SrcID, DOPhieuX DOX)
        {
            List<DOFWObjRelData> listObjRel = new List<DOFWObjRelData>();
            try
            {
                ITonKho data = (ITonKho)DOX;
                DataSet ds_hanghoa = data.GetTonKho().DataSet;

                DataSet PinMap_ds = Get_TableColumnMap(plTrans, DOX.GetPhieuType().GetTypeID());

                if (PinMap_ds != null && PinMap_ds.Tables.Count > 0)
                {
                    DataTable PinMap = PinMap_ds.Tables[0];
                    string HangHoa_ID = PinMap.Rows[0]["PIN_HANG_HOA"] != null ?
                        PinMap.Rows[0]["PIN_HANG_HOA"].ToString().Trim() : "";
                    string SoLuong = PinMap.Rows[0]["PIN_SO_LUONG"] != null ?
                        PinMap.Rows[0]["PIN_SO_LUONG"].ToString().Trim() : "";
                    string TrongLuong = PinMap.Rows[0]["PIN_TRONG_LUONG"] != null ?
                        PinMap.Rows[0]["PIN_TRONG_LUONG"].ToString().Trim() : "";
                    string DonGia = PinMap.Rows[0]["PIN_DON_GIA"] != null ?
                        PinMap.Rows[0]["PIN_DON_GIA"].ToString().Trim() : "";
                    string TTHTK_ID = PinMap.Rows[0]["PIN_TTHTK"] != null ?
                        PinMap.Rows[0]["PIN_TTHTK"].ToString().Trim() : "";

                    if (HangHoa_ID != "" && ds_hanghoa.Tables.Count > 0 &&
                        ds_hanghoa.Tables[0].Columns.Contains(HangHoa_ID))
                    {
                        foreach (DataRow dr in ds_hanghoa.Tables[0].Rows)
                        {
                            DOFWObjRelData ObjRel = new DOFWObjRelData();
                            ObjRel.SRC_ID = SrcID;
                            ObjRel.SRC_TYPE = Src;
                            ObjRel.DES_ID = DOX.GetID();
                            ObjRel.DES_TYPE = DOX.GetPhieuType().GetTypeID();
                            ObjRel.HH_ID = HelpNumber.ParseInt64(dr[HangHoa_ID]);
                            if (SoLuong != "" && ds_hanghoa.Tables[0].Columns.Contains(SoLuong))
                                ObjRel.SO_LG = HelpNumber.ParseDecimal(dr[SoLuong]);
                            if (TrongLuong != "" && ds_hanghoa.Tables[0].Columns.Contains(TrongLuong))
                                ObjRel.TONG_TR_LG = HelpNumber.ParseDecimal(dr[TrongLuong]);

                            ObjRel.NGUOI_CAP_NHAT = data.GetNguoiCapNhat();
                            ObjRel.NGAY_CAP_NHAT = data.GetNgayCapNhat();
                            ObjRel.NGUOI_PHAT_SINH = data.GetNguoiPhatSinh();
                            ObjRel.NGAY_PHAT_SINH = data.GetNgayPhatSinh();

                            string inout1 = PinMap.Rows[0]["INOUT1"].ToString();//INOUT1FromType(plTrans, ObjRel.DES_TYPE);
                            if (inout1 != "")
                            {
                                ObjRel.INOUT1 = inout1;
                                if (inout1 == "OUT" || inout1 == "IN")
                                    ObjRel.KHO_ID1 = data.GetKho1();
                            }
                            else
                                ObjRel.INOUT1 = "";
                            string inout2 = PinMap.Rows[0]["INOUT2"].ToString();//INOUT2FromType(plTrans, ObjRel.DES_TYPE);
                            if (inout2 == "OUT" || inout2 == "IN")
                            {
                                ObjRel.INOUT2 = inout2;
                                ObjRel.KHO_ID2 = data.GetKho2();
                            }
                            else
                                ObjRel.INOUT2 = "";

                            long dvt_id = DVTFromHH_ID(plTrans, ObjRel.HH_ID);
                            if (dvt_id != -1)
                                ObjRel.DON_VI_TINH = dvt_id;
                            if (DonGia != "" && ds_hanghoa.Tables[0].Columns.Contains(DonGia))
                                ObjRel.GIA = HelpNumber.ParseDecimal(dr[DonGia]);
                            if (TTHTK_ID != "" && ds_hanghoa.Tables[0].Columns.Contains(TTHTK_ID))
                                ObjRel.TINH_TRANG_HH = HelpNumber.ParseInt64(dr[TTHTK_ID]);
                            ObjRel.GHI_CHU = dr["GHI_CHU"] != null ? dr["GHI_CHU"].ToString() : "";
                            listObjRel.Add(ObjRel);
                        }
                        return listObjRel;
                    }
                    else
                        return listObjRel;
                }
                else
                    return listObjRel;
            }
            catch (Exception ex)
            {
                plTrans.Rollback();
                PLException.AddException(ex);
                return listObjRel;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Kiểm tra đối tượng DOFWObjRelData có trong danh sách hay không dựa vào 
 /// des_id, des_type, hh_id, tinh_trang_hh
 /// </summary>
 /// <param name="listObjRel">Danh sách đối tượng DOFWObjRelData</param>
 /// <param name="objRel">Đối tượng DOFWObjRelData cần kiểm tra</param>
 /// <returns></returns>
 public static bool Check_DOFWObjRelDataInList(List<DOFWObjRelData> listObjRel, DOFWObjRelData objRel)
 {
     foreach (DOFWObjRelData obj in listObjRel)
     {
         if ((obj.DES_ID == objRel.DES_ID) && (obj.DES_TYPE == objRel.DES_TYPE)
             && (obj.HH_ID == objRel.HH_ID) && (obj.TINH_TRANG_HH == objRel.TINH_TRANG_HH))
             return true;
     }
     return false;
 }
Esempio n. 6
0
        public bool Update(PLTransaction plTrans, DOFWObjRelData Data, bool IsUpdate,long ky_id)
        {
            if (Data == null) return true;
            DatabaseFB db = plTrans.db;
            DbTransaction dbTrans = plTrans.dbTrans;
            try
            {
                if (IsUpdate)
                {
                    string sql = "update kho_ton_kho_" +
                        ky_id +
                        " set src_id=@src_id" +
                        ",src_type=@src_type" +
                        ",so_lg=@so_luong" +
                        ",tong_tr_lg=@tong_trong_luong" +
                        ",nguoi_cap_nhat=@nguoi_cap_nhat" +
                        ",ngay_cap_nhat=@ngay_cap_nhat" +
                        ",nguoi_phat_sinh=@nguoi_phat_sinh" +
                        ",ngay_phat_sinh=@ngay_phat_sinh" +
                        ",kho_id1=@kho_id1" +
                        ",kho_id2=@kho_id2" +
                        ",don_vi_tinh=@don_vi_tinh" +
                        ",gia=@gia" +
                        ",tinh_trang_hh=@tinh_trang_hh" +
                        " where des_id=@des_id" +
                        " and des_type=@des_type" +
                        " and hh_id=@hh_id" +
                        " and tinh_trang_hh=@tinh_trang_hh";

                    DbCommand cmd_Update = db.GetSQLStringCommand(sql);
                    db.AddInParameter(cmd_Update, "@src_id", DbType.Int64, Data.SRC_ID);
                    db.AddInParameter(cmd_Update, "@src_type", DbType.Int32, Data.SRC_TYPE);
                    db.AddInParameter(cmd_Update, "@des_id", DbType.Int64, Data.DES_ID);
                    db.AddInParameter(cmd_Update, "@des_type", DbType.Int32, Data.DES_TYPE);
                    db.AddInParameter(cmd_Update, "@hh_id", DbType.Int64, Data.HH_ID);
                    db.AddInParameter(cmd_Update, "@so_luong", DbType.Decimal, Data.SO_LG);
                    db.AddInParameter(cmd_Update, "@tong_trong_luong", DbType.Decimal, Data.TONG_TR_LG);
                    db.AddInParameter(cmd_Update, "@nguoi_cap_nhat", DbType.Int64, Data.NGUOI_CAP_NHAT);
                    db.AddInParameter(cmd_Update, "@ngay_cap_nhat", DbType.DateTime, Data.NGAY_CAP_NHAT);
                    db.AddInParameter(cmd_Update, "@nguoi_phat_sinh", DbType.Int64, Data.NGUOI_PHAT_SINH);
                    db.AddInParameter(cmd_Update, "@ngay_phat_sinh", DbType.DateTime, Data.NGAY_PHAT_SINH);
                    db.AddInParameter(cmd_Update, "@kho_id1", DbType.Int64, Data.KHO_ID1);
                    db.AddInParameter(cmd_Update, "@kho_id2", DbType.Int64, Data.KHO_ID2);
                    db.AddInParameter(cmd_Update, "@don_vi_tinh", DbType.Int64, Data.DON_VI_TINH);
                    db.AddInParameter(cmd_Update, "@gia", DbType.Decimal, Data.GIA);
                    db.AddInParameter(cmd_Update, "@tinh_trang_hh", DbType.Int64, Data.TINH_TRANG_HH);

                    db.ExecuteNonQuery(cmd_Update, plTrans.dbTrans);
                }
                else
                {
                    string sql = "insert into kho_ton_kho_" +
                        ky_id +
                        " values(@id_tem, @src_id, @src_type, @des_id, @des_type, @hh_id, @so_luong, " +
                        "@tong_trong_luong, @nguoi_cap_nhat, @ngay_cap_nhat, @nguoi_phat_sinh, " +
                        "@ngay_phat_sinh, @inout1, @kho_id1, @inout2, @kho_id2, @don_vi_tinh, " +
                        "@gia, @tinh_trang_hh)";
                    DbCommand cmd_Insert = db.GetSQLStringCommand(sql);
                    if (Data.ID_TEM <= 0)
                        Data.ID_TEM = db.GetID(HelpGen.G_FW_ID, dbTrans);
                    db.AddInParameter(cmd_Insert, "@id_tem", DbType.Int64, Data.ID_TEM);
                    db.AddInParameter(cmd_Insert, "@src_id", DbType.Int64, Data.SRC_ID);
                    db.AddInParameter(cmd_Insert, "@src_type", DbType.Int32, Data.SRC_TYPE);
                    db.AddInParameter(cmd_Insert, "@des_id", DbType.Int64, Data.DES_ID);
                    db.AddInParameter(cmd_Insert, "@des_type", DbType.Int32, Data.DES_TYPE);
                    db.AddInParameter(cmd_Insert, "@hh_id", DbType.Int64, Data.HH_ID);
                    db.AddInParameter(cmd_Insert, "@so_luong", DbType.Decimal, Data.SO_LG);
                    db.AddInParameter(cmd_Insert, "@tong_trong_luong", DbType.Decimal, Data.TONG_TR_LG);
                    db.AddInParameter(cmd_Insert, "@nguoi_cap_nhat", DbType.Int64, Data.NGUOI_CAP_NHAT);
                    db.AddInParameter(cmd_Insert, "@ngay_cap_nhat", DbType.DateTime, Data.NGAY_CAP_NHAT);
                    db.AddInParameter(cmd_Insert, "@nguoi_phat_sinh", DbType.Int64, Data.NGUOI_PHAT_SINH);
                    db.AddInParameter(cmd_Insert, "@ngay_phat_sinh", DbType.DateTime, Data.NGAY_PHAT_SINH);
                    db.AddInParameter(cmd_Insert, "@inout1", DbType.String, Data.INOUT1);
                    db.AddInParameter(cmd_Insert, "@kho_id1", DbType.Int64, Data.KHO_ID1);
                    db.AddInParameter(cmd_Insert, "@inout2", DbType.String, Data.INOUT2);
                    db.AddInParameter(cmd_Insert, "@kho_id2", DbType.Int64, Data.KHO_ID2);
                    db.AddInParameter(cmd_Insert, "@don_vi_tinh", DbType.Int64, Data.DON_VI_TINH);
                    db.AddInParameter(cmd_Insert, "@gia", DbType.Decimal, Data.GIA);
                    db.AddInParameter(cmd_Insert, "@tinh_trang_hh", DbType.Int64, Data.TINH_TRANG_HH);

                    db.ExecuteNonQuery(cmd_Insert, dbTrans);
                }
            }
            catch (Exception ex)
            {
                PLException.AddException(ex);
                return false;
            }
            return true;
        }