public int Add_Product_Dealer_Data_MAster(Product_Add_Dealer_Temp obj) { // int createdby = 0; //DataTable DT = Helper.Helper.ToDataTable(obj.Packages); //DataSet ds = new DataSet(); //ds.Tables.Add(DT); //string PackageXml = ds.GetXml(); //if (ds.Tables[0].Rows.Count > 0) //{ // createdby = Convert.ToInt32(ds.Tables[0].Rows[0]["dealerID"]); // obj.CreatedBy = createdby; //} int flag = _dealerDal.Add_Product_Dealer_Data_Master(obj); return(flag); }
public int Add_Product_Dealer_Data_Temp(Product_Add_Dealer_Temp objProducttemp, string packageData) { string sql = ""; DataSet ds = new DataSet(); int iResult = 0; try { if (objProducttemp.CreatedBy > 0) { objProducttemp.CreatedDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); } if (objProducttemp.ModifiedBy > 0) { objProducttemp.ModifiedDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); } sql = StoredProcedure.Add_Product_Package_Data_Temp; SqlParameter[] parameters = new SqlParameter[31]; parameters[0] = new SqlParameter("@OldProductId", objProducttemp.ProductId); parameters[1] = new SqlParameter("@ProductType", objProducttemp.ProductType); parameters[2] = new SqlParameter("@productName", objProducttemp.ProductName); parameters[3] = new SqlParameter("@TechnicalId", objProducttemp.TechnicalID); parameters[4] = new SqlParameter("@BrandId", objProducttemp.BrandID); parameters[5] = new SqlParameter("@ProductStateId", objProducttemp.StateID); parameters[6] = new SqlParameter("@Dosage", objProducttemp.DosageID); parameters[7] = new SqlParameter("@ApplyOnCrop", objProducttemp.ApplyOnCrop); parameters[8] = new SqlParameter("@Target", objProducttemp.Target); parameters[9] = new SqlParameter("@ProductDesc", objProducttemp.ProductDesc); parameters[10] = new SqlParameter("@Remark", objProducttemp.Remark); parameters[11] = new SqlParameter("@CreateBy", objProducttemp.CreatedBy); if (objProducttemp.CreatedBy > 0) { parameters[12] = new SqlParameter("@CreatedDate", objProducttemp.CreatedDate); } parameters[13] = new SqlParameter("@ModifiedBy", objProducttemp.ModifiedBy); if (objProducttemp.ModifiedBy > 0) { parameters[14] = new SqlParameter("@ModifiedDate", objProducttemp.ModifiedDate); } parameters[15] = new SqlParameter("@PackageTypeId", objProducttemp.PackageTypeID); parameters[16] = new SqlParameter("@QualityId", objProducttemp.QualityID); parameters[17] = new SqlParameter("@CropID", objProducttemp.CropID); parameters[18] = new SqlParameter("@Disease", objProducttemp.Disease); parameters[19] = new SqlParameter("@FeedType", objProducttemp.FeedType); parameters[20] = new SqlParameter("@FeedState", objProducttemp.FeedState); parameters[21] = new SqlParameter("@status", objProducttemp.status); parameters[22] = new SqlParameter("@Technical_Name", objProducttemp.otherTechnicalName); if (!string.IsNullOrEmpty(objProducttemp.otherCompanyName.Trim())) { parameters[23] = new SqlParameter("@Company_Name", objProducttemp.otherCompanyName); } parameters[24] = new SqlParameter("@Brand_Name", objProducttemp.otherBrandName); parameters[25] = new SqlParameter("@Packagedata", packageData); parameters[26] = new SqlParameter("@ProductId", 0); parameters[26].Direction = ParameterDirection.Output; parameters[27] = new SqlParameter("@IsActive", objProducttemp.IsActive); parameters[28] = new SqlParameter("@SubcategoryId", objProducttemp.SubCategoryID); parameters[29] = new SqlParameter("@CategoryID", objProducttemp.CategoryID); if (string.IsNullOrEmpty(objProducttemp.otherCompanyName.Trim())) { parameters[30] = new SqlParameter("@Company_Name", "ID-" + objProducttemp.CompanyID); } iResult = BaseDal.ExecuteNonQuerywithSP(sql, parameters); iResult = Convert.ToInt32(parameters[26].Value); if (iResult > 0) { if (objProducttemp.ProductUserFor != null) { // var objproductuserfor = obj.ProductUserFor.FirstOrDefault(); foreach (DealerTbl_ProductUseFor objproductuserfor in objProducttemp.ProductUserFor) { if (objproductuserfor.UseFor > 0) { sql = StoredProcedure.Add_Update_DealerProductUseFor; SqlParameter[] parameter = new SqlParameter[13]; parameter[0] = new SqlParameter("@ProductId", objProducttemp.ProductId > 0 ? objProducttemp.ProductId : iResult); parameter[1] = new SqlParameter("@UseFor", objproductuserfor.UseFor); parameter[2] = new SqlParameter("@Category", objproductuserfor.Category); parameter[3] = new SqlParameter("@Srange", objproductuserfor.Srange); parameter[4] = new SqlParameter("@Erange", objproductuserfor.Erange); parameter[5] = new SqlParameter("@RangeUnit", objproductuserfor.RangeUnit); parameter[6] = new SqlParameter("@Remark", objproductuserfor.Remark); parameter[7] = new SqlParameter("@CreateBy", objproductuserfor.CreateBy); parameter[8] = new SqlParameter("@ModifiedBy", objproductuserfor.ModifiedBy); parameter[10] = new SqlParameter("@Id", objproductuserfor.Id); parameter[11] = new SqlParameter("@Isactive", objproductuserfor.IsActive); parameter[12] = new SqlParameter("@status", objproductuserfor.status); int i = BaseDal.ExecuteNonQuerywithSP(sql, parameter); } } } if (objProducttemp.otherCompoundCattleFeed != null) { Add_Nutrient_value(objProducttemp.otherCompoundCattleFeed, objProducttemp.SubCategoryID, false, objProducttemp.ProductId > 0 ? objProducttemp.ProductId : iResult); } } //if (iResult > 0) // iResult = 1; } catch (Exception ex) { LogDal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0); } return(iResult); }
public int Add_Product_Dealer_Data_Master(Product_Add_Dealer_Temp objProducttemp) { string sql = ""; DataSet ds = new DataSet(); int iResult = 0, ioutput = 0; try { if (objProducttemp.CreatedBy > 0) { objProducttemp.CreatedDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); } if (objProducttemp.ModifiedBy > 0) { objProducttemp.ModifiedDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); } sql = StoredProcedure.Add_Package_Dealer_master; if (objProducttemp.ProductId > 0) { if (objProducttemp.Packages != null) { // var objproductuserfor = obj.ProductUserFor.FirstOrDefault(); foreach (Prod_Package_Add_dealer objproductuserfor in objProducttemp.Packages) { if (objproductuserfor.dealerID > 0 && objproductuserfor.packageId == 0) { sql = StoredProcedure.Add_Package_Dealer_master; SqlParameter[] parameter = new SqlParameter[14]; parameter[0] = new SqlParameter("@productid", objProducttemp.ProductId > 0 ? objProducttemp.ProductId : iResult); parameter[1] = new SqlParameter("@dealerID", objproductuserfor.dealerID); parameter[2] = new SqlParameter("@dealerPrice", objproductuserfor.dealerPrice); parameter[3] = new SqlParameter("@isActive", objproductuserfor.isActive); parameter[4] = new SqlParameter("@mrp", objproductuserfor.mrp); parameter[5] = new SqlParameter("@othercharges", objproductuserfor.othercharges); parameter[6] = new SqlParameter("@packageId", objproductuserfor.packageId); parameter[7] = new SqlParameter("@qty", objproductuserfor.qty); parameter[8] = new SqlParameter("@size", objproductuserfor.size); parameter[10] = new SqlParameter("@unitID", objproductuserfor.unitID); parameter[11] = new SqlParameter("@createdby", objProducttemp.CreatedBy); parameter[12] = new SqlParameter("@ourPrice", objproductuserfor.ourPrice); parameter[13] = new SqlParameter("@IsPackageAdded", 0); parameter[13].Direction = ParameterDirection.Output; int i = BaseDal.ExecuteNonQuerywithSP(sql, parameter); ioutput = Convert.ToInt32(parameter[13].Value); } } } } if (ioutput > 0) { iResult = 1; } } catch (Exception ex) { LogDal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0); } return(iResult); }