Ejemplo n.º 1
0
 protected void btnCreatnew_Click(object sender, EventArgs e)
 {
     try
     {
         string mcl       = txtMaClaim.Text;
         int    madv      = int.Parse(drSubsidiary.SelectedItem.Value.ToString());
         int    maGDV     = int.Parse(drSurveyor.SelectedItem.Value.ToString());
         int    idloaihtt = int.Parse(drTypeofloss.SelectedItem.Value.ToString());
         clm.Follower = drSurveyor.SelectedItem.ToString();
         if (madv != 0 && maGDV != 0 && idloaihtt != 0)
         {
             string mahoaDV  = dvdao.LayMaHoa(madv);
             string matenGDV = gdv.LayMaTen(maGDV);
             string tendonvi = drSubsidiary.SelectedItem.Text;
             string tengdv   = drSurveyor.SelectedItem.Text;
             int    maKH     = khdao.LayMaKH();
             // them khach hang moi
             khdto.MaKhachHang = maKH;
             string tenKH = txtInsurerd.Text;
             if (tenKH != "")
             {
                 khdto.TenKhachHang = tenKH;
             }
             else
             {
                 Response.Write("<script>alert('Name of insured can not empty!!');</script>");
             }
             khdto.TenNguoiDaiDien = "";
             khdto.Email           = "";
             khdto.DienThoai       = "";
             khdto.Fax             = "";
             khdto.DiaChi          = "";
             khdto.MaDonViBH       = madv;
             bool themKH = khdao.KhachHangMoi(khdto);
             if (themKH == true)// hop le thi them claim
             {
                 clm.MaClaim     = mcl;
                 clm.TenClaim    = mcl + mahoaDV + "-" + drTypePolicy.SelectedItem.Value + "-" + txtTypePolicy.Text;
                 clm.MaDonVi     = (int)madv;
                 clm.MaGDV1      = (int)maGDV;
                 clm.MaKhachHang = maKH;
                 if (idloaihtt != 0)
                 {
                     clm.MaloaiHinhTonThat = (int)idloaihtt;
                 }
                 else
                 {
                     Response.Write("<script>alert('Please select Type of Loss!');</script>");
                 }
                 string ghichu = txtGhiChu.Text;
                 if (ghichu != "")
                 {
                     clm.GhiChu = ghichu;
                 }
                 else
                 {
                     clm.GhiChu = "";
                 }
                 string ngaychidinh = txtAssignedDate.Text;
                 if (ngaychidinh != "")
                 {
                     clm.AssignedDate = ngaychidinh;
                 }
                 else
                 {
                     clm.AssignedDate = "";
                 }
                 string tp = txtTypePolicy.Text;
                 if (tp == "")
                 {
                     Response.Write("<script>alert('Type Police can not empty!');</script>");
                 }
                 else
                 {
                     clm.TypePolicy = tp;
                     bool themclaim = cldao.InsertShort(clm);
                     if (themclaim == true)
                     {
                         sm.SendNewClaim(clm, khdto, tendonvi, tengdv);
                         Session["IDClaim"]   = mcl;
                         Session["ThamChieu"] = mcl;
                         int    GDVThem = int.Parse(Request.Cookies["MaGDV"].Value);
                         string noidung = gdv.LayTenTheoMa(GDVThem) + " created new claim no. " + mcl + ".";
                         SaveLogTracking(GDVThem, noidung, mcl);
                         ClearInputs(Page.Controls);
                         //Response.Redirect("~/Pages/TypeItemWorkSheet.aspx");
                         //lblThongBao.Text = "Insert successful!";
                         Response.Write("<script>window.parent.location = '../Pages/Layout.aspx'</script>");
                     }
                 }
             }
         }
         else
         {
             lblThongBao.Text = "Please choose item in dropdonwlist!";
         }
     }
     catch (SqlException ex)
     {
         lblThongBao.Text = ex.Message;
     }
 }
Ejemplo n.º 2
0
        protected void btnCreatnew_Click(object sender, EventArgs e)
        {
            try
            {
                string mcl       = txtMaClaim.Text;
                int    madv      = int.Parse(drSubsidiary.SelectedItem.Value.ToString());
                int    maGDV     = int.Parse(drSurveyor.SelectedItem.Value.ToString());
                int    idloaihtt = int.Parse(drTypeofloss.SelectedItem.Value.ToString());
                clm.Follower = drSurveyor.SelectedItem.ToString();
                if (madv != 0 && maGDV != 0 && idloaihtt != 0)
                {
                    string mahoaDV  = dvdao.LayMaHoa(madv);
                    string matenGDV = gdv.LayMaTen(maGDV);
                    string tendonvi = drSubsidiary.SelectedItem.Text;
                    string tengdv   = drSurveyor.SelectedItem.Text;
                    int    maKH     = khdao.LayMaKH();
                    // them khach hang moi
                    khdto.MaKhachHang = maKH;
                    string tenKH = txtInsurerd.Text;
                    if (tenKH != "")
                    {
                        khdto.TenKhachHang = tenKH;
                    }
                    else
                    {
                        Response.Write("<script>alert('Name of insured can not empty!!');</script>");
                    }
                    khdto.TenNguoiDaiDien = "";
                    khdto.Email           = "";
                    khdto.DienThoai       = "";
                    khdto.Fax             = "";
                    khdto.DiaChi          = "";
                    khdto.MaDonViBH       = madv;
                    bool themKH = khdao.KhachHangMoi(khdto);
                    if (themKH == true)// hop le thi them claim
                    {
                        clm.MaClaim  = mcl;
                        clm.TenClaim = mcl + mahoaDV + "-" + drTypePolicy.SelectedItem.Value + "-" + txtTypePolicy.Text;
                        clm.MaDonVi  = (int)madv;
                        clm.MaGDV1   = (int)maGDV;
                        //string nguoichidinh = txtHandler.Text;
                        //if (nguoichidinh != "")
                        //    clm.NguoiPhuTrach = nguoichidinh;
                        //else
                        //    clm.NguoiPhuTrach = "";
                        clm.MaKhachHang = maKH;
                        //string sohd = txtPolicyNo.Text;
                        //if (sohd != "")
                        //    clm.PolicyNo = sohd;
                        //else
                        //    clm.PolicyNo = "";
                        //string hieuluc = txtEffective.Text;
                        //if (hieuluc != "")
                        //    clm.Effective = hieuluc;
                        //else
                        //    clm.Effective = "";

                        if (idloaihtt != 0)
                        {
                            clm.MaloaiHinhTonThat = (int)idloaihtt;
                        }
                        else
                        {
                            Response.Write("<script>alert('Please select Type of Loss!');</script>");
                        }
                        string ghichu = txtGhiChu.Text;
                        if (ghichu != "")
                        {
                            clm.GhiChu = ghichu;
                        }
                        else
                        {
                            clm.GhiChu = "";
                        }
                        //string date = txtDateofloss.Text;
                        //if (date != "")
                        //    clm.Dol = date;
                        //else
                        //    clm.Dol = "";
                        //string diadiemtt = txtPresmises.Text;
                        //if (diadiemtt != "")
                        //    clm.Premises = diadiemtt;
                        //else
                        //    clm.Premises = "";
                        string ngaychidinh = txtAssignedDate.Text;
                        if (ngaychidinh != "")
                        {
                            clm.AssignedDate = ngaychidinh;
                        }
                        else
                        {
                            clm.AssignedDate = "";
                        }
                        #region Oldcode

                        //string dienbientonthat = ckDienBienTonThat.Text;
                        //if (dienbientonthat != "")
                        //    clm.DienBienTonThat1 = dienbientonthat;
                        //else
                        //    clm.DienBienTonThat1 = "";
                        //string thongbaocqcn = "";
                        //if (ckYes.Checked == true)
                        //{
                        //    thongbaocqcn = "Yes";
                        //    clm.ThongBaoCQCN1=thongbaocqcn;
                        //    //ckNo.Checked = false;
                        //}
                        //if (ckNo.Checked == true)
                        //{
                        //    thongbaocqcn = "No";
                        //    clm.ThongBaoCQCN1=thongbaocqcn;
                        //    //ckYes.Checked = false;
                        //}
                        //if (ckNo.Checked == false && ckYes.Checked == false)
                        //    clm.ThongBaoCQCN1 = "No";

                        //string ghichutbcqcn = txtFurthernotes.Text;
                        //if (ghichutbcqcn != "")
                        //    clm.GhiChuTBCQCN = ghichutbcqcn;
                        //else
                        //    clm.GhiChuTBCQCN = "";
                        //string phamvitonthat = ckExtentofloss.Text;
                        //if (phamvitonthat != "")
                        //    clm.PhamViTonThat = phamvitonthat;
                        //else
                        //    clm.PhamViTonThat = "";
                        //string duphong = txtintitialreserve.Text;
                        //if (duphong != "")
                        //    clm.DuPhongTonThat = duphong;
                        //else
                        //    clm.DuPhongTonThat = "";
                        //string phuluc = txtappendixattached.Text;
                        //if (phuluc != "")
                        //    clm.PhuLucDinhKem1 = phuluc;
                        //else
                        //    clm.PhuLucDinhKem1 = "";
                        //string dephongvakhuyencao = ckDePhongTonThatVaKhuyenCao.Text;
                        //if (dephongvakhuyencao != "")
                        //    clm.DePhongVaKhuyenCao = dephongvakhuyencao;
                        //else
                        //    clm.DePhongVaKhuyenCao = "";
                        //string ykien = ckYKienGDV.Text;
                        //if (ykien != "")
                        //    clm.YKienGDV = ykien;
                        //else
                        //    clm.YKienGDV = "";
                        //clm.GioKhaoSatHienTruong = txtTimeComplete.Text;
                        #endregion
                        string tp = txtTypePolicy.Text;
                        if (tp == "")
                        {
                            Response.Write("<script>alert('Type Police can not empty!');</script>");
                        }
                        else
                        {
                            clm.TypePolicy = tp;
                            bool themclaim = cldao.InsertShort(clm);
                            if (themclaim == true)
                            {
                                ClearInputs(Page.Controls);
                                sm.SendNewClaim(clm, khdto, tendonvi, tengdv);
                                //Response.Redirect(Request.Url.PathAndQuery, true);// làm sạch textbox
                                Session["IDClaim"] = mcl;
                                Response.Redirect("~/Pages/TypeItemWorkSheet.aspx");
                            }
                        }
                    }
                }
                else
                {
                    lblThongBao.Text = "Please choose item in dropdonwlist!";
                }
            }
            catch (SqlException ex)
            {
                lblThongBao.Text = ex.Message;
            }
        }