Esempio n. 1
0
        public string InsertPSParameter(string parameterName, string parameterCode, string mode, string status, string flag, string columnName)
        {
            string result = string.Empty;

            try
            {
                DataControl.CurrentInfo objCurInfo = new CurrentInfo();
                DataControl.BLProduct   objProduct = new BLProduct();

                List <MVCModels.HiDoctor_Master.PrimarySalesParametersModel> lstCheckParam = new List <MVCModels.HiDoctor_Master.PrimarySalesParametersModel>();
                lstCheckParam = (List <MVCModels.HiDoctor_Master.PrimarySalesParametersModel>)objProduct.GetAllPSParameters(objCurInfo.GetCompanyCode());
                if ("INSERT" == mode.ToUpper())
                {
                    var fileterd = lstCheckParam.AsEnumerable().Where(z => z.Param_Column_Name.ToUpper() == columnName.ToUpper()).ToList();
                    if (fileterd.Count > 0)
                    {
                        result = "ERROR:Primary sales column name must be unique";
                    }
                }
                if ("EDIT" == mode.ToUpper())
                {
                    var fileterd = lstCheckParam.AsEnumerable().Where(z => z.Param_Column_Name.ToUpper() == columnName.ToUpper()).ToList();
                    if (fileterd.Count > 0)
                    {
                        if (fileterd[0].Parameter_Code != parameterCode)
                        {
                            result = "ERROR:Primary sales column name must be unique";
                        }
                    }
                }
                if (string.IsNullOrEmpty(result))
                {
                    int rowsAffected = 0;
                    List <MVCModels.HiDoctor_Master.PrimarySalesParametersModel> lstParam = new List <MVCModels.HiDoctor_Master.PrimarySalesParametersModel>();
                    MVCModels.HiDoctor_Master.PrimarySalesParametersModel        objParam = new MVCModels.HiDoctor_Master.PrimarySalesParametersModel();
                    objParam.Parameter_Name    = parameterName;
                    objParam.Parameter_Code    = parameterCode;
                    objParam.Record_Status     = status;
                    objParam.Param_Column_Name = columnName;
                    objParam.Flag         = flag;
                    objParam.Company_Code = objCurInfo.GetCompanyCode();
                    lstParam.Add(objParam);
                    rowsAffected = objProduct.InsertPSParameters(objCurInfo.GetCompanyCode(), mode, lstParam);
                    if (rowsAffected > 0)
                    {
                        if (mode.ToUpper() == "INSERT")
                        {
                            result = "SUCCESS:Primary sales parameter added successfully";
                        }
                        else if (mode.ToUpper() == "EDIT")
                        {
                            result = "SUCCESS:Primary sales parameter updated successfully";
                        }
                        else
                        {
                            result = "SUCCESS:Primary sales parameter status chnaged successfully";
                        }
                    }
                    else
                    {
                        result = "ERROR:Primary sales parameter updation failed";
                    }
                }
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dicContext = new Dictionary <string, string>();
                DataControl.Impl.ExceptionHandler.WriteLog(ex, dicContext);
            }
            return(result);
        }