예제 #1
0
 protected void grdDVT_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     try
     {
         SYS_Session session = (SYS_Session)Session["SYS_Session"];
         CBDN.DM_TramSelectByIDDViResult HoatDong = (CBDN.DM_TramSelectByIDDViResult)grdDVT.GetRow(grdDVT.FocusedRowIndex);
         if (HoatDong.MaDVNhap != int.Parse(session.User.ma_dviqly))
         {
             ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Không thể xóa giao nhận này vì không phải đơn vị bạn tạo ra');", true);
             return;
         }
         CBDN.DM_Tram cv = new CBDN.DM_Tram();
         cv = db.DM_Trams.SingleOrDefault(x => x.IDTram == cv.IDTram && x.IDChiNhanh == cv.IDChiNhanh);
         db.DM_Trams.DeleteOnSubmit(cv);
         db.SubmitChanges();
         _DataBind();
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Xoá người phụ trách thành công');", true);
     }
     catch (Exception ex)
     { }
     finally
     {
         e.Cancel = true;
     }
 }
예제 #2
0
        protected void TreeListOrganization_NodeDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            try
            {
                SYS_Session session = (SYS_Session)Session["SYS_Session"];

                CBDN.DM_Tram HoatDong = db.DM_Trams.SingleOrDefault(x => x.IDTram == int.Parse(e.Keys["IDTram"] + ""));
                if (HoatDong.MaDVNhap != int.Parse(session.User.ma_dviqly))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Không thể xóa trạm lộ này vì không phải đơn vị bạn tạo ra');", true);
                    return;
                }
                var check = db.DM_DiemDos.Where(x => x.IDTram == HoatDong.IDTram + "");
                if (check.Count() > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Không thể xóa trạm lộ này vì có điểm đo đang hoạt động ');", true);
                    return;
                }
                CBDN.DM_Tram cv = new CBDN.DM_Tram();
                cv = db.DM_Trams.SingleOrDefault(x => x.IDTram == HoatDong.IDTram);
                db.DM_Trams.DeleteOnSubmit(cv);
                db.SubmitChanges();
                _DataBind();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Xoá danh mục thành công');", true);
            }
            catch (Exception ex)
            { }
            finally
            {
                e.Cancel = true;
            }
        }
예제 #3
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            SYS_Session session = (SYS_Session)Session["SYS_Session"];

            if (Session["Add"] + "" == "0")
            {
                CBDN.DM_TramSelectByIDDViResult cv = (CBDN.DM_TramSelectByIDDViResult)grdDVT.GetRow(grdDVT.FocusedRowIndex);
                //var lst = db.DM_Trams.Where(x => x.MaTram == cv.MaTram && x.IDChiNhanh==cv.IDChiNhanh);

                if (cmbDuongDay.Value + "" == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Bạn phải chọn phương thức giao nhận');", true);
                    return;
                }
                if (!CheckName(txtMaDuongDat.Text, cv.IDTram, cmbDuongDay.Value + ""))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã trạm không được trùng');", true); return;
                }
                if (txtTenDuongDay.Value + "" == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Tên trạm không thể bỏ trống');", true);
                    return;
                }
                CBDN.DM_Tram qtCT = db.DM_Trams.Single(x => x.IDTram == cv.IDTram);
                //foreach (var qtCT in lst)
                //{
                qtCT.TenTram = txtTenDuongDay.Text;
                qtCT.MoTa    = txtmoTa.Text;
                qtCT.DiaDiem = "";
                if (cmbDuongDay.Value + "" != "")
                {
                    qtCT.IDChiNhanh = cmbDuongDay.Value + "";
                }
                else
                {
                    qtCT.IDChiNhanh = "";
                    qtCT.IDDuongDay = 0;
                }
                if (CkHoatDong.Checked)
                {
                    qtCT.HoatDong = 1;
                }
                else
                {
                    qtCT.HoatDong = 0;
                }
                db.SubmitChanges();

                //}

                //CBDN.DM_Tram qtCT = new CBDN.DM_Tram();
            }
            else
            {
                if (txtMaDuongDat.Text + "" == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã trạm không được để trống');", true);
                    txtMaDuongDat.Focus(); return;
                }
                if (txtTenDuongDay.Text == "")
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Tên trạm không được để trống');", true);
                    txtTenDuongDay.Focus(); return;
                }

                if (!CheckName(txtMaDuongDat.Text, 0, cmbDuongDay.Value + ""))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Mã trạm không được trùng');", true); return;
                }

                var cn = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(cmbDuongDay.Value + "") && x.IDMADVIQLY.Contains(session.User.ma_dviqly));
                //var lstDD = db.DM_ChiNhanhs.Where(x => x.MaChiNhanh == cn.MaChiNhanh);
                //foreach (var dd in lstDD)
                //{
                CBDN.DM_Tram cv = new CBDN.DM_Tram();
                cv.MaTram     = txtMaDuongDat.Text;
                cv.IDMaDviQly = cn.IDMADVIQLY;
                cv.TenTram    = txtTenDuongDay.Text;
                cv.MoTa       = txtmoTa.Text;
                cv.TinhChatDD = int.Parse(cmbTinhChat.Value + "");
                cv.DiaDiem    = "";
                if (cmbDuongDay.Value + "" != "")
                {
                    cv.IDDuongDay = cn.ID;
                    cv.IDChiNhanh = cn.ID + "";
                }
                else
                {
                    cv.IDDuongDay = 0;
                    cv.IDChiNhanh = "";
                }
                if (CkHoatDong.Checked)
                {
                    cv.HoatDong = 1;
                }
                else
                {
                    cv.HoatDong = 0;
                }
                cv.MaDVNhap = int.Parse(session.User.ma_dviqly);
                db.DM_Trams.InsertOnSubmit(cv);
                db.SubmitChanges();

                //}
            }
            pcAddRoles.ShowOnPageLoad = false;
            _DataBind();
        }
예제 #4
0
        private void insertdulieu()
        {
            SystemManageService.DM_DVQLYService dvi = new SystemManageService.DM_DVQLYService();
            DataTable dt = new DataTable();

            dt = dbOR.SelectAllDDo_TT("RG");
            if (dt == null)
            {
                return;
            }

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var donvi  = dvi.SelectAllDM_DVQLY().SingleOrDefault(x => x.MA_DVIQLY == dt.Rows[i]["MA_DVIQLY"] + "");
                var donviG = dvi.SelectAllDM_DVQLY().SingleOrDefault(x => x.MA_DVIQLY == dt.Rows[i]["DVIGIAO"] + "");
                if (!CheckName(dt.Rows[i]["MA_DVI"] + "", 0, donvi.MA_DVIQLY))
                {
                    continue;
                }
                if (!CheckName(dt.Rows[i]["MA_DVIB"] + "", 0, donvi.MA_DVIQLY))
                {
                    continue;
                }

                CBDN.DM_ChiNhanh cv = new CBDN.DM_ChiNhanh();
                cv.TenChiNhanh = dt.Rows[i]["MOTA"] + "";
                cv.MaChiNhanh  = dt.Rows[i]["MA_DVI"] + "";
                if (dt.Rows[i]["CHIEU_GNHAN"] + "" == "G")
                {
                    cv.IDMADVIQLY = "," + donvi.IDMA_DVIQLY + "," + donviG.IDMA_DVIQLY + ",";
                }
                else
                {
                    cv.IDMADVIQLY = "," + donviG.IDMA_DVIQLY + "," + donvi.IDMA_DVIQLY + ",";
                }
                if (donvi.MA_DVIQLY == "PA" || donviG.MA_DVIQLY == "PA")
                {
                    cv.LoaiPhuongThuc = 1;
                }
                else if (donvi.MA_DVIQLY.Length == 4 && donviG.MA_DVIQLY.Length == 4)
                {
                    cv.LoaiPhuongThuc = 2;
                }
                else if (donvi.MA_DVIQLY.Length + donviG.MA_DVIQLY.Length < 12 && donvi.MA_DVIQLY.Length + donviG.MA_DVIQLY.Length > 9)
                {
                    cv.LoaiPhuongThuc = 3;
                }
                else
                {
                    cv.LoaiPhuongThuc = 4;
                }
                cv.MoTa = dt.Rows[i]["MOTA"] + "";
                if (dt.Rows[i]["CHIEU_GNHAN"] + "" == "G")
                {
                    cv.DiemDauNguon  = donvi.IDMA_DVIQLY;
                    cv.DiemCuoiNguon = donviG.IDMA_DVIQLY;
                }
                else
                {
                    cv.DiemCuoiNguon = donvi.IDMA_DVIQLY;
                    cv.DiemDauNguon  = donviG.IDMA_DVIQLY;
                }


                cv.HoatDong = 1;
                cv.HoatDong = 0;
                db.DM_ChiNhanhs.InsertOnSubmit(cv);
                db.SubmitChanges();
            }
            // insert tram
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var donvi  = dvi.SelectAllDM_DVQLY().SingleOrDefault(x => x.MA_DVIQLY == dt.Rows[i]["MA_DVIQLY"] + "");
                var donviG = dvi.SelectAllDM_DVQLY().SingleOrDefault(x => x.MA_DVIQLY == dt.Rows[i]["DVIGIAO"] + "");
                var cn     = db.DM_ChiNhanhs.SingleOrDefault(x => x.MaChiNhanh == dt.Rows[i]["MA_DVI"] + "");
                if (!CheckNameTramLo(dt.Rows[i]["MA_PTDIEN"] + "", 0, cn.ID + ""))
                {
                    continue;
                }

                //var cn = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(cmbDuongDay.Value + "") && x.IDMADVIQLY.Contains(session.User.ma_dviqly));
                //var lstDD = db.DM_ChiNhanhs.Where(x => x.MaChiNhanh == cn.MaChiNhanh);
                //foreach (var dd in lstDD)
                //{
                CBDN.DM_Tram cv = new CBDN.DM_Tram();
                cv.MaTram = dt.Rows[i]["MA_PTDIEN"] + "";

                cv.IDMaDviQly = cn.IDMADVIQLY;
                cv.TenTram    = dt.Rows[i]["MA_PTDIEN"] + "";
                cv.MoTa       = "";
                cv.TinhChatDD = 0;
                cv.DiaDiem    = "";

                cv.IDDuongDay = cn.ID;
                cv.IDChiNhanh = cn.ID + "";

                cv.HoatDong = 1;
                cv.ParentId = 0;
                cv.IsLo     = 0;
                cv.MaDVNhap = donviG.IDMA_DVIQLY;
                db.DM_Trams.InsertOnSubmit(cv);
                db.SubmitChanges();
            }
            // insert ma diem do
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var donviG = dvi.SelectAllDM_DVQLY().SingleOrDefault(x => x.MA_DVIQLY == dt.Rows[i]["DVIGIAO"] + "");
                var cn     = db.DM_ChiNhanhs.SingleOrDefault(x => x.MaChiNhanh == dt.Rows[i]["MA_DVI"] + "");
                var tr     = db.DM_Trams.SingleOrDefault(x => x.MaTram == dt.Rows[i]["MA_PTDIEN"] + "" && x.IDMaDviQly.Contains(cn.IDMADVIQLY));
                if (!CheckNameDiemDo(dt.Rows[i]["MA_DDO"] + "", "0", tr.IDMaDviQly + ""))
                {
                    continue;
                }
                //var tr = db.DM_Trams.SingleOrDefault(x => x.IDTram == int.Parse(tlDonVi.FocusedNode.Key + "") && x.IDMaDviQly.Contains("," + session.User.ma_dviqly + ","));

                CBDN.DM_DiemDo cv = new CBDN.DM_DiemDo();
                cv.MaDiemDo   = dt.Rows[i]["MA_DDO"] + "";
                cv.IDMaDViQly = tr.IDMaDviQly;
                cv.TenDiemDo  = dt.Rows[i]["MA_DDO"] + "";
                cv.MoTa       = "";
                cv.IDChiNhanh = tr.IDChiNhanh;
                cv.IDTram     = tr.IDTram + "";
                cv.TinhChatDD = 0;
                cv.ISLoaiDD   = 0;
                cv.HoatDong   = 1;
                cv.MaDviNhap  = donviG.IDMA_DVIQLY;
                db.DM_DiemDos.InsertOnSubmit(cv);
                db.SubmitChanges();
                //}
            }

            DataTable dtCongTo = new DataTable();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var donvi  = dvi.SelectAllDM_DVQLY().SingleOrDefault(x => x.MA_DVIQLY == dt.Rows[i]["MA_DVIQLY"] + "");
                var donviG = dvi.SelectAllDM_DVQLY().SingleOrDefault(x => x.MA_DVIQLY == dt.Rows[i]["DVIGIAO"] + "");
                dtCongTo = dbOR.SelectAllCongTo(dt.Rows[i]["MA_DDO"] + "");
                if (dtCongTo.Rows.Count > 0)
                {
                    var listddo = db.DM_DiemDos.Where(x => x.MaDiemDo == dt.Rows[i]["MA_DDO"] + "");

                    foreach (var ddo in listddo)
                    {// List<Entity.DM_DVQLY> lst = new List<DM_DVQLY>();
                        //var ddo = db.DM_DiemDos.SingleOrDefault(x => x.IDDiemDo == int.Parse(cmbDiemDo.Value + "") && x.IDMaDViQly.Contains(session.User.ma_dviqly));
                        if (!CheckNameCongTo(dtCongTo.Rows[0]["MA_TBI"] + "", 0, ddo.IDTram, ddo.IDChiNhanh))
                        {
                            continue;
                        }
                        //foreach (var ddo in lst)
                        //{
                        CBDN.DM_CongTo cv = new CBDN.DM_CongTo();
                        cv.MaCongTo  = dtCongTo.Rows[0]["MA_TBI"] + "";
                        cv.TenCongTo = dtCongTo.Rows[0]["SO_TBI"] + "";
                        cv.MoTa      = "";
                        cv.IDDiemDo  = ddo.IDDiemDo + "";

                        cv.IDDonViQuanLy = ddo.IDMaDViQly;

                        cv.TinhTrang    = 1;
                        cv.CapDienAp    = dtCongTo.Rows[0]["CAPDA"] + "";
                        cv.ChungLoai    = "";
                        cv.HangSanXuat  = "";
                        cv.HeSoNhan     = decimal.Parse(dtCongTo.Rows[0]["HSN"] + "");
                        cv.NgayTreoThao = DateTime.Now;
                        cv.TU_TI        = "";
                        cv.IDTram       = ddo.IDTram;
                        cv.IDChiNhanh   = ddo.IDChiNhanh;

                        if (dt.Rows[i]["CHIEU_GNHAN"] + "" == "G")
                        {
                            cv.IDDonViGiao    = donvi.IDMA_DVIQLY;
                            cv.KenhGiaoCongTo = "G";
                            cv.GiaoTinhChat   = 0;

                            cv.IDDonViNhan    = donviG.IDMA_DVIQLY;
                            cv.KenhNhanCongTo = "N";
                            cv.NhanTinhChat   = 0;
                        }
                        else
                        {
                            cv.IDDonViGiao    = donviG.IDMA_DVIQLY;
                            cv.KenhGiaoCongTo = "G";
                            cv.GiaoTinhChat   = 0;

                            cv.IDDonViNhan    = donvi.IDMA_DVIQLY;
                            cv.KenhNhanCongTo = "N";
                            cv.NhanTinhChat   = 0;
                        }

                        cv.IDUser       = 1;
                        cv.NgayTao      = DateTime.Now;
                        cv.NgayKiemDinh = DateTime.Now;
                        cv.HeSoQuyDoi   = 1;
                        cv.IDDVNhapDL   = donviG.IDMA_DVIQLY;

                        cv.IDDVXacNhan = donvi.IDMA_DVIQLY;
                        cv.IsCToMotGia = false;
                        db.DM_CongTos.InsertOnSubmit(cv);
                        db.SubmitChanges();



                        //}
                        var congto = db.DM_CongTos.SingleOrDefault(x => x.IDCongTo == cv.IDCongTo);
                        //CBDN.DM_CongToSelectByIDDViResult HoatDong = (CBDN.DM_CongToSelectByIDDViResult)grdDVT.GetRow(grdDVT.FocusedRowIndex);
                        CBDN.HD_GiaoNhanThang giaonhan = new CBDN.HD_GiaoNhanThang();
                        giaonhan.IDCongTo   = congto.IDCongTo + "";
                        giaonhan.IDChiNhanh = congto.IDChiNhanh;
                        giaonhan.IDDuongDay = congto.IDChiNhanh;
                        giaonhan.IDMaDViQly = donviG.IDMA_DVIQLY;
                        giaonhan.IDUser     = 1;
                        giaonhan.IDTram     = congto.IDTram;
                        if (DateTime.Now.Month == 1)
                        {
                            giaonhan.Thang = 12;
                            giaonhan.Nam   = DateTime.Now.Year - 1;
                        }

                        else
                        {
                            giaonhan.Thang = DateTime.Now.Month - 1;
                            giaonhan.Nam   = DateTime.Now.Year;
                        }
                        giaonhan.Nhan_P_Dau      = 0;
                        giaonhan.Giao_P_Dau      = 0;
                        giaonhan.Giao_P_SanLuong = 0;
                        giaonhan.Nhan_P_SanLuong = 0;

                        giaonhan.Nhan_Q_Dau      = 0;
                        giaonhan.Giao_Q_Dau      = 0;
                        giaonhan.Giao_Q_SanLuong = 0;
                        giaonhan.Nhan_Q_SanLuong = 0;


                        giaonhan.CosGiao = 0;

                        giaonhan.CosNhan = 0;


                        giaonhan.Giao_Bieu1_Dau      = 0;
                        giaonhan.Nhan_Bieu1_Dau      = 0;
                        giaonhan.Giao_Bieu1_SanLuong = 0;
                        giaonhan.Nhan_Bieu1_SanLuong = 0;

                        giaonhan.Giao_Bieu2_Dau      = 0;
                        giaonhan.Nhan_Bieu2_Dau      = 0;
                        giaonhan.Giao_Bieu2_SanLuong = 0;
                        giaonhan.Nhan_Bieu2_SanLuong = 0;

                        giaonhan.Giao_Bieu3_Dau      = 0;
                        giaonhan.Nhan_Bieu3_Dau      = 0;
                        giaonhan.Giao_Bieu3_SanLuong = 0;
                        giaonhan.Nhan_Bieu3_SanLuong = 0;
                        giaonhan.ISDoDem             = 0;
                        giaonhan.ISChot   = false;
                        giaonhan.LoaiNhap = 0;
                        giaonhan.NgayNhap = DateTime.Now;
                        db.HD_GiaoNhanThangs.InsertOnSubmit(giaonhan);
                        db.SubmitChanges();
                    }
                }
            }
        }
예제 #5
0
        protected void btnSua_Click(object sender, EventArgs e)
        {
            pcAddRoles.ShowOnPageLoad = true;
            Session["Add"]            = 0;
            loadPhuongThuc();
            SYS_Session session = (SYS_Session)Session["SYS_Session"];

            CBDN.DM_Tram tram = db.DM_Trams.SingleOrDefault(x => x.IDTram == int.Parse(TreeListOrganization.FocusedNode.Key + ""));
            txtMaDuongDat.Text  = tram.MaTram;
            txtTenDuongDay.Text = tram.TenTram;
            cmbDuongDay.Value   = tram.IDChiNhanh;
            cmbDuongDay.Text    = db.DM_ChiNhanhs.SingleOrDefault(x => x.ID == int.Parse(tram.IDChiNhanh)).TenChiNhanh;
            cmbCDA.Value        = tram.TinhChatDD;

            if (tram.TinhChatDD == 0)
            {
                cmbCDA.Text = "550 kV";
            }
            else if (tram.TinhChatDD == 0)
            {
                cmbCDA.Text = "220 kV";
            }
            else if (tram.TinhChatDD == 0)
            {
                cmbCDA.Text = "110 kV";
            }
            else if (tram.TinhChatDD == 0)
            {
                cmbCDA.Text = "350 kV";
            }
            else if (tram.TinhChatDD == 0)
            {
                cmbCDA.Text = "22 kV";
            }
            else
            if (tram.TinhChatDD == 0)
            {
                cmbCDA.Text = "10 kV";
            }
            else if (tram.TinhChatDD == 0)
            {
                cmbCDA.Text = "6 kV";
            }
            else
            {
                cmbCDA.Text = "0.4 kV";
            }


            cmbTinhChat.Value = tram.IsLo;
            if (tram.IsLo == 0)
            {
                cmbTinhChat.Text = "Trạm";
            }
            else
            {
                cmbTinhChat.Text = "Lộ";
            }
            if (tram.HoatDong == 1)
            {
                CkHoatDong.Checked = true;
            }
            else
            {
                CkHoatDong.Checked = false;
            }
            txtmoTa.Text = tram.MoTa;
            //txtDiaChi.Value = cv.DiaDiem;
        }