Example #1
0
        public LabourDetails InsertLabour(string FullName, string FatherName, string CurrentAddress, string CurrentStateID, string CurrentCityID, string CurrentPincode, string PermanentAddress, string PermanentStateID, string PermanentCityID, string PermanentPincode, string PhoneNo, string SectorType, string LabourType, string Specialization, string Experience, string Wages, string Lbr_Skill, string Bool_Verification, string SupplierID, string Belonging1, string Belonging2, string Belonging3, string Belonging4)
        {
            LabourDetails labourDetails = new LabourDetails();
            Labour labour = new Labour();
            SupplierDAL supplierDAL = new SupplierDAL();
            System.Net.WebHeaderCollection webHeaderCollection = WebOperationContext.Current.IncomingRequest.Headers;
            try
            {
                #region Url Decoding...
                FullName = HttpUtility.UrlDecode(FullName);
                FatherName = HttpUtility.UrlDecode(FatherName);
                CurrentAddress = HttpUtility.UrlDecode(CurrentAddress);
                CurrentStateID = HttpUtility.UrlDecode(CurrentStateID);
                CurrentCityID = HttpUtility.UrlDecode(CurrentCityID);
                CurrentPincode = HttpUtility.UrlDecode(CurrentPincode);
                PermanentAddress = HttpUtility.UrlDecode(PermanentAddress);
                PermanentStateID = HttpUtility.UrlDecode(PermanentStateID);
                PermanentCityID = HttpUtility.UrlDecode(PermanentCityID);
                PermanentPincode = HttpUtility.UrlDecode(PermanentPincode);
                PhoneNo = HttpUtility.UrlDecode(PhoneNo);
                SectorType = HttpUtility.UrlDecode(SectorType);
                LabourType = HttpUtility.UrlDecode(LabourType);
                Specialization = HttpUtility.UrlDecode(Specialization);
                Experience = HttpUtility.UrlDecode(Experience);
                Wages = HttpUtility.UrlDecode(Wages);
                Lbr_Skill = HttpUtility.UrlDecode(Lbr_Skill);
                Bool_Verification = HttpUtility.UrlDecode(Bool_Verification);
                SupplierID = HttpUtility.UrlDecode(SupplierID);
                Belonging1 = HttpUtility.UrlDecode(Belonging1);
                Belonging2 = HttpUtility.UrlDecode(Belonging2);
                Belonging3 = HttpUtility.UrlDecode(Belonging3);
                Belonging4 = HttpUtility.UrlDecode(Belonging4);
                #endregion

                #region Labour Code Generate
                string Sector = "";
                string LabourTypeCurrentCityPreFix = supplierDAL.GetLabourTypeCityPreFixCode(LabourType, CurrentCityID);
                //string CurrentCityPreFix = "";

                string CodePostFix = SupplierDAL.GenerateCodeWithLeftPad("tbl_LabourRegistration", "Reg_ID", 6, "", false);
                if (SectorType == "1")
                    Sector = "HH";
                else if (SectorType == "2")
                    Sector = "GL";
                else
                    Sector = "IL";
                string CodePrefix = Sector + LabourTypeCurrentCityPreFix + CurrentPincode.Substring(4, 2);
                string LabourCode = CodePrefix + CodePostFix;
                #endregion

                labour.LabourCode = LabourCode.ToUpper() == "NULL" ? "" : LabourCode;
                labour.FullName = FullName.ToUpper() == "NULL" ? "" : FullName;
                labour.FatherName = FatherName.ToUpper() == "NULL" ? "" : FatherName;
                labour.CurrentAddress = CurrentAddress.ToUpper() == "NULL" ? "" : CurrentAddress;
                labour.CurrentStateID = CurrentStateID.ToUpper() == "NULL" ? 0 : Convert.ToInt32(CurrentStateID); ;
                labour.CurrentCityID = CurrentCityID.ToUpper() == "NULL" ? 0 : Convert.ToInt32(CurrentCityID); ;
                labour.CurrentPincode = CurrentPincode.ToUpper() == "NULL" ? 0 : Convert.ToInt32(CurrentPincode);
                labour.PermanentAddress = PermanentAddress.ToUpper() == "NULL" ? "" : PermanentAddress;
                labour.PermanentStateID = PermanentStateID.ToUpper() == "NULL" ? 0 : Convert.ToInt32(PermanentStateID);
                labour.PermanentCityID = PermanentCityID.ToUpper() == "NULL" ? 0 : Convert.ToInt32(PermanentCityID); ;
                labour.PermanentPincode = PermanentPincode.ToUpper() == "NULL" ? 0 : Convert.ToInt32(PermanentPincode);
                labour.PhoneNo = PhoneNo.ToUpper() == "NULL" ? "0" : PhoneNo;
                labour.SectorType = SectorType.ToUpper() == "NULL" ? "0" : SectorType;
                labour.LabourType = LabourType.ToUpper() == "NULL" ? "0" : LabourType;
                labour.Specialization = Specialization.ToUpper() == "NULL" ? "0" : Specialization;
                labour.Experience = Experience.ToUpper() == "NULL" ? 0 : Convert.ToInt32(Experience);
                labour.Wages = Wages.ToUpper() == "NULL" ? 0 : Convert.ToInt32(Wages);
                labour.Lbr_Skill = Lbr_Skill.ToUpper() == "NULL" ? "" : Lbr_Skill;
                labour.Verification = Bool_Verification.ToUpper() == "NULL" ? false : true;
                labour.SupplierID = SupplierID.ToUpper() == "NULL" ? 0 : Convert.ToInt32(SupplierID);
                labour.Belonging1 = Belonging1.ToUpper() == "NULL" ? "0" : Belonging1;
                labour.Belonging2 = Belonging2.ToUpper() == "NULL" ? "0" : Belonging2;
                labour.Belonging3 = Belonging3.ToUpper() == "NULL" ? "0" : Belonging3;
                labour.Belonging4 = Belonging4.ToUpper() == "NULL" ? "0" : Belonging4;

                labour.Image_URL = webHeaderCollection["Image_URL"] == null ? "" : webHeaderCollection["Image_URL"].ToString();
                labour.Doc1_URL = webHeaderCollection["Doc1_URL"] == null ? "" : webHeaderCollection["Doc1_URL"].ToString();
                labour.Doc2_URL = webHeaderCollection["Doc2_URL"] == null ? "" : webHeaderCollection["Doc2_URL"].ToString();
                labour.Doc3_URL = webHeaderCollection["Doc3_URL"] == null ? "" : webHeaderCollection["Doc3_URL"].ToString();
                labour.Doc4_URL = webHeaderCollection["Doc4_URL"] == null ? "" : webHeaderCollection["Doc4_URL"].ToString();

                supplierDAL.InsertNewLabourData("INSERT", labour);
                labourDetails.Message = "Labour inserted successfully !";
                labourDetails.Status = true;
                return labourDetails;
            }
            catch (Exception exception)
            {
                Logger Err = new Logger();
                Err.ErrorLog(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ErrorLogPath"]), exception.Message, exception.StackTrace);
                labourDetails.Message = "Error occured and logged please connect the Service Manager !";
                labourDetails.Status = false;
                return labourDetails;
            }
        }