Beispiel #1
0
        public void CapNhatTapTin(QLSC_TAPTIN objTapTin)
        {
            var obj = Get_TapTin(objTapTin.FILE_ID);

            obj.FILE_NAME           = objTapTin.FILE_NAME;
            obj.FILE_MOTA           = objTapTin.FILE_MOTA;
            obj.FILE_EXT            = objTapTin.FILE_EXT;
            obj.FILE_NGAYCAPNHAT    = objTapTin.FILE_NGAYCAPNHAT;
            obj.FILE_SIZE           = objTapTin.FILE_SIZE;
            obj.FILE_USERID_CAPNHAT = objTapTin.FILE_USERID_CAPNHAT;
            obj.OBJECT_ID           = objTapTin.OBJECT_ID;
            obj.OBJECT_LOAI         = objTapTin.OBJECT_LOAI;

            context.SubmitChanges();
        }
Beispiel #2
0
 public void ThemTapTin(QLSC_TAPTIN objTapTin)
 {
     context.QLSC_TAPTINs.InsertOnSubmit(objTapTin);
     context.SubmitChanges();
 }
Beispiel #3
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            try
            {
                objNGUOIDUNG = vDC.QLSC_NGUOIDUNGs.Where(x => x.UserID == _currentUser.UserID).SingleOrDefault();
                if (vSC_ID == 0)//Thêm mới sự cố
                {
                    objSUCO        = new QLSC_SUCO();
                    objSUCO.UserID = _currentUser.UserID;
                    if (_currentUser.IsInRole("Administrator"))
                    {
                        if (drpDonVi.SelectedValue != null)
                        {
                            objSUCO.DONVI_ID = int.Parse(drpDonVi.SelectedValue);
                        }
                    }
                    else
                    {
                        if (objNGUOIDUNG != null)
                        {
                            objSUCO.DONVI_ID = objNGUOIDUNG.DONVI_ID;
                        }
                        else
                        {
                            objSUCO.DONVI_ID = 1;
                        }
                    }
                    objSUCO.LOAISC_ID = int.Parse(drpLoaiSuCo.SelectedValue);
                    //Thời gian xãy ra sự cố
                    string   ctrl_ngayxayra   = txtNgayXayRaSuCo.SelectedDate.ToString();
                    string[] temptxtngayxayra = ctrl_ngayxayra.Split(' ');
                    string   gioxayra         = drpGioXayRa.SelectedValue;
                    string   phutxayra        = drpPhutXayra.SelectedValue;
                    string   ngayxayra        = temptxtngayxayra[0] + " " + gioxayra + ":" + phutxayra + ":00";
                    string   tg_xayra         = DateTime.Parse(ngayxayra).ToString("yyyy-MM-dd HH:mm:ss");
                    DateTime dt_xayra         = DateTime.Parse(ngayxayra);
                    objSUCO.SC_NGAYXAYRA = dt_xayra;
                    //Thời gian tái lập
                    string   ctrl_ngaytailap   = txtNgayXayRaSuCo.SelectedDate.ToString();
                    string[] temptxtngaytailap = ctrl_ngaytailap.Split(' ');
                    string   giotailap         = drpGioTaiLap.SelectedValue;
                    string   phuttailap        = drpPhutTaiLap.SelectedValue;
                    string   ngaytailap        = temptxtngayxayra[0] + " " + giotailap + ":" + phuttailap + ":00";
                    string   tg_tailap         = DateTime.Parse(ngaytailap).ToString("yyyy-MM-dd HH:mm:ss");
                    DateTime dt_tailap         = DateTime.Parse(ngayxayra);
                    objSUCO.SC_NGAYTAILAP = dt_tailap;

                    objSUCO.SC_NOIDUNG    = ClassCommon.ClearHTML(txtNoiDungSuCo.Text.Trim());
                    objSUCO.SC_NGUYENNHAN = ClassCommon.ClearHTML(txtNguyenNhan.Text.Trim());

                    objSUCO.SC_VTTB_TENCHUNGLOAI = ClassCommon.ClearHTML(txtTenChungLoai1.Text.Trim());
                    if (txtSoLuong1.Text != "")
                    {
                        objSUCO.SC_VTTB_SOLUONG = int.Parse(txtSoLuong1.Text.ToString().Replace(".", ""));
                    }

                    objSUCO.SC_VTTB_NHASANXUAT = ClassCommon.ClearHTML(txtNhaSX1.Text.Trim());
                    objSUCO.SC_VTTB_NAMVANHANH = ClassCommon.ClearHTML(txtNamVanHanh1.Text.Trim());

                    objSUCO.SC_VTTB_TENCHUNGLOAI2 = ClassCommon.ClearHTML(txtTenChungLoai2.Text.Trim());
                    if (txtSoLuong1.Text != "")
                    {
                        objSUCO.SC_VTTB_SOLUONG2 = int.Parse(txtSoLuong2.Text.ToString().Replace(".", ""));
                    }

                    objSUCO.SC_VTTB_NHASANXUAT2 = ClassCommon.ClearHTML(txtNhaSanXuat2.Text.Trim());
                    objSUCO.SC_VTTB_NAMVANHANH2 = ClassCommon.ClearHTML(txtNamVanHanh2.Text.Trim());

                    objSUCO.SC_VTTB_TENCHUNGLOAI3 = ClassCommon.ClearHTML(txtTenChungLoai3.Text.Trim());
                    if (txtSoLuong1.Text != "")
                    {
                        objSUCO.SC_VTTB_SOLUONG3 = int.Parse(txtSoLuong3.Text.ToString().Replace(".", ""));
                    }

                    objSUCO.SC_VTTB_NHASANXUAT3 = ClassCommon.ClearHTML(txtNhaSanXuat3.Text.Trim());
                    objSUCO.SC_VTTB_NAMVANHANH3 = ClassCommon.ClearHTML(txtNamVanHanh3.Text.Trim());

                    objSUCO.SC_VTTB_TENCHUNGLOAI4 = ClassCommon.ClearHTML(txtTenChungLoai4.Text.Trim());


                    if (txtSoLuong1.Text != "")
                    {
                        objSUCO.SC_VTTB_SOLUONG4 = int.Parse(txtSoLuong4.Text.ToString().Replace(".", ""));
                    }
                    objSUCO.SC_VTTB_NHASANXUAT4 = ClassCommon.ClearHTML(txtNhaSanXuat4.Text.Trim());
                    objSUCO.SC_VTTB_NAMVANHANH4 = ClassCommon.ClearHTML(txtNamVanHanh4.Text.Trim());

                    objSUCO.SC_VTTB_TENCHUNGLOAI5 = ClassCommon.ClearHTML(txtTenChungLoai5.Text.Trim());
                    if (txtSoLuong1.Text != "")
                    {
                        objSUCO.SC_VTTB_SOLUONG5 = int.Parse(txtSoLuong5.Text.ToString().Replace(".", ""));
                    }

                    objSUCO.SC_VTTB_NHASANXUAT5 = ClassCommon.ClearHTML(txtNhaSanXuat5.Text.Trim());
                    objSUCO.SC_VTTB_NAMVANHANH5 = ClassCommon.ClearHTML(txtNamVanHanh5.Text.Trim());

                    objSUCO.SC_THIETBIDONGCAT_MSRCS = ClassCommon.ClearHTML(txtThietBiDongCat.Text.Trim());

                    objSUCO.SC_DIENAP = int.Parse(DienAp.SelectedValue);
                    int vKQ = rd_CQ_KQ.SelectedValue == "KQ" ? 1 : 0;
                    objSUCO.SC_KQ = vKQ;
                    int vCQ = rd_CQ_KQ.SelectedValue == "CQ" ? 1 : 0;
                    objSUCO.SC_CQ = vCQ;

                    objSUCO.SC_LOAI = int.Parse(drpPhanLoai.SelectedValue);
                    if (txtTongSoKH.Text.Trim() != "")
                    {
                        objSUCO.SC_TONGSOKH = Int32.Parse(txtTongSoKH.Text.ToString().Replace(".", ""));
                    }
                    objSUCO.SC_TAISAN = int.Parse(TaiSan.SelectedValue);
                    objSUCO.SC_GHICHU = ClassCommon.ClearHTML(txtGhiChu.Text.Trim());

                    vDC.QLSC_SUCOs.InsertOnSubmit(objSUCO);
                    vDC.SubmitChanges();

                    if (dgDanhSach.Rows.Count > 0)
                    {
                        DataTable dt = Session["dgDanhSach"] as DataTable;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            objTapTin                     = new QLSC_TAPTIN();
                            objTapTin.FILE_NAME           = dt.Rows[i]["HA_FILE_PATH"].ToString();
                            objTapTin.FILE_MOTA           = dt.Rows[i]["HA_TENFILE"].ToString();
                            objTapTin.FILE_EXT            = dt.Rows[i]["HA_EXT"].ToString();
                            objTapTin.FILE_SIZE           = Int32.Parse(dt.Rows[i]["HA_SIZE"].ToString());
                            objTapTin.FILE_USERID_CAPNHAT = _currentUser.UserID;
                            objTapTin.FILE_NGAYCAPNHAT    = DateTime.Now;
                            objTapTin.OBJECT_LOAI         = (int)CommonEnum.TapTinObjectLoai.File;
                            objTapTin.OBJECT_ID           = objSUCO.SC_ID;
                            objTAPTINController.ThemTapTin(objTapTin);
                        }
                    }
                    else
                    {
                    }
                    Session.Remove("dgDanhSach");
                }
                else //cập nhật sự cố
                {
                    objSUCO = vDC.QLSC_SUCOs.Where(x => x.SC_ID == vSC_ID).SingleOrDefault();
                    if (objSUCO != null)
                    {
                        objSUCO.LOAISC_ID = int.Parse(drpLoaiSuCo.SelectedValue);
                        //Thời gian xãy ra sự cố
                        string   ctrl_ngayxayra   = txtNgayXayRaSuCo.SelectedDate.ToString();
                        string[] temptxtngayxayra = ctrl_ngayxayra.Split(' ');
                        string   gioxayra         = drpGioXayRa.SelectedValue;
                        string   phutxayra        = drpPhutXayra.SelectedValue;
                        string   ngayxayra        = temptxtngayxayra[0] + " " + gioxayra + ":" + phutxayra + ":00";
                        string   tg_xayra         = DateTime.Parse(ngayxayra).ToString("yyyy-MM-dd HH:mm:ss");
                        DateTime dt_xayra         = DateTime.Parse(ngayxayra);
                        objSUCO.SC_NGAYXAYRA = dt_xayra;
                        //Thời gian tái lập
                        string   ctrl_ngaytailap   = txtNgayXayRaSuCo.SelectedDate.ToString();
                        string[] temptxtngaytailap = ctrl_ngaytailap.Split(' ');
                        string   giotailap         = drpGioTaiLap.SelectedValue;
                        string   phuttailap        = drpPhutTaiLap.SelectedValue;
                        string   ngaytailap        = temptxtngayxayra[0] + " " + giotailap + ":" + phuttailap + ":00";
                        string   tg_tailap         = DateTime.Parse(ngaytailap).ToString("yyyy-MM-dd HH:mm:ss");
                        DateTime dt_tailap         = DateTime.Parse(ngayxayra);
                        objSUCO.SC_NGAYTAILAP = dt_tailap;

                        if (drpDonVi.SelectedValue != null)
                        {
                            objSUCO.DONVI_ID = int.Parse(drpDonVi.SelectedValue);
                        }

                        objSUCO.SC_NOIDUNG    = ClassCommon.ClearHTML(txtNoiDungSuCo.Text.Trim());
                        objSUCO.SC_NGUYENNHAN = ClassCommon.ClearHTML(txtNguyenNhan.Text.Trim());

                        objSUCO.SC_VTTB_TENCHUNGLOAI = ClassCommon.ClearHTML(txtTenChungLoai1.Text.Trim());
                        if (txtSoLuong1.Text != "")
                        {
                            objSUCO.SC_VTTB_SOLUONG = int.Parse(txtSoLuong1.Text.ToString().Replace(".", ""));
                        }

                        objSUCO.SC_VTTB_NHASANXUAT = ClassCommon.ClearHTML(txtNhaSX1.Text.Trim());
                        objSUCO.SC_VTTB_NAMVANHANH = ClassCommon.ClearHTML(txtNamVanHanh1.Text.Trim());

                        objSUCO.SC_VTTB_TENCHUNGLOAI2 = ClassCommon.ClearHTML(txtTenChungLoai2.Text.Trim());
                        if (txtSoLuong2.Text != "")
                        {
                            objSUCO.SC_VTTB_SOLUONG2 = int.Parse(txtSoLuong2.Text.ToString().Replace(".", ""));
                        }

                        objSUCO.SC_VTTB_NHASANXUAT2 = ClassCommon.ClearHTML(txtNhaSanXuat2.Text.Trim());
                        objSUCO.SC_VTTB_NAMVANHANH2 = ClassCommon.ClearHTML(txtNamVanHanh2.Text.Trim());

                        objSUCO.SC_VTTB_TENCHUNGLOAI3 = ClassCommon.ClearHTML(txtTenChungLoai3.Text.Trim());
                        if (txtSoLuong3.Text != "")
                        {
                            objSUCO.SC_VTTB_SOLUONG3 = int.Parse(txtSoLuong3.Text.ToString().Replace(".", ""));
                        }

                        objSUCO.SC_VTTB_NHASANXUAT3 = ClassCommon.ClearHTML(txtNhaSanXuat3.Text.Trim());
                        objSUCO.SC_VTTB_NAMVANHANH3 = ClassCommon.ClearHTML(txtNamVanHanh3.Text.Trim());

                        objSUCO.SC_VTTB_TENCHUNGLOAI4 = ClassCommon.ClearHTML(txtTenChungLoai4.Text.Trim());


                        if (txtSoLuong4.Text != "")
                        {
                            objSUCO.SC_VTTB_SOLUONG4 = int.Parse(txtSoLuong4.Text.ToString().Replace(".", ""));
                        }
                        objSUCO.SC_VTTB_NHASANXUAT4 = ClassCommon.ClearHTML(txtNhaSanXuat4.Text.Trim());
                        objSUCO.SC_VTTB_NAMVANHANH4 = ClassCommon.ClearHTML(txtNamVanHanh4.Text.Trim());

                        objSUCO.SC_VTTB_TENCHUNGLOAI5 = ClassCommon.ClearHTML(txtTenChungLoai5.Text.Trim());
                        if (txtSoLuong5.Text != "")
                        {
                            objSUCO.SC_VTTB_SOLUONG5 = int.Parse(txtSoLuong5.Text.ToString().Replace(".", ""));
                        }

                        objSUCO.SC_VTTB_NHASANXUAT5 = ClassCommon.ClearHTML(txtNhaSanXuat5.Text.Trim());
                        objSUCO.SC_VTTB_NAMVANHANH5 = ClassCommon.ClearHTML(txtNamVanHanh5.Text.Trim());

                        objSUCO.SC_THIETBIDONGCAT_MSRCS = ClassCommon.ClearHTML(txtThietBiDongCat.Text.Trim());

                        objSUCO.SC_DIENAP = int.Parse(DienAp.SelectedValue);
                        int vKQ = rd_CQ_KQ.SelectedValue == "KQ" ? 1 : 0;
                        objSUCO.SC_KQ = vKQ;
                        int vCQ = rd_CQ_KQ.SelectedValue == "CQ" ? 1 : 0;
                        objSUCO.SC_CQ = vCQ;

                        objSUCO.SC_LOAI = int.Parse(drpPhanLoai.SelectedValue);
                        if (txtTongSoKH.Text.Trim() != "")
                        {
                            objSUCO.SC_TONGSOKH = Int32.Parse(txtTongSoKH.Text.ToString().Replace(".", ""));
                        }
                        objSUCO.SC_TAISAN = int.Parse(TaiSan.SelectedValue);
                        objSUCO.SC_GHICHU = ClassCommon.ClearHTML(txtGhiChu.Text.Trim());
                        vDC.SubmitChanges();

                        var objTT = objTAPTINController.Get_TapTin_By_ObjectID_LoaiID(vSC_ID, (int)CommonEnum.TapTinObjectLoai.File);
                        foreach (var it1 in objTT)
                        {
                            objTAPTINController.XOA_TAPTIN(it1.FILE_ID);
                        }
                        if (dgDanhSach.Rows.Count > 0)
                        {
                            DataTable dt    = Session["dgDanhSach"] as DataTable;
                            string    fname = dt.Rows[0]["HA_FILE_PATH"].ToString();
                            dt    = Session["dgDanhSach"] as DataTable;
                            fname = dt.Rows[0]["HA_FILE_PATH"].ToString();
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                objTapTin                     = new QLSC_TAPTIN();
                                objTapTin.FILE_NAME           = dt.Rows[i]["HA_FILE_PATH"].ToString();
                                objTapTin.FILE_MOTA           = dt.Rows[i]["HA_TENFILE"].ToString();
                                objTapTin.FILE_EXT            = dt.Rows[i]["HA_EXT"].ToString();
                                objTapTin.FILE_SIZE           = Int32.Parse(dt.Rows[i]["HA_SIZE"].ToString());
                                objTapTin.FILE_USERID_CAPNHAT = _currentUser.UserID;
                                objTapTin.FILE_NGAYCAPNHAT    = DateTime.Now;
                                objTapTin.OBJECT_LOAI         = (int)CommonEnum.TapTinObjectLoai.File;
                                objTapTin.OBJECT_ID           = vSC_ID;
                                objTAPTINController.ThemTapTin(objTapTin);
                            }
                        }
                        Session.Remove("dgDanhSach");
                    }
                }
                Session[TabId + _currentUser.UserID + "_Message"] = "Cập nhật đơn hàng thành công";
                Session[TabId + _currentUser.UserID + "_Type"]    = "success";
                Response.Redirect(Globals.NavigateURL(), true);
            }
            catch (Exception ex)
            {
                ClassCommon.ShowToastr(Page, "Có lỗi xãy ra, vui lòng liên hệ quản trị", "Thông báo", "error");
            }
        }