public string GenrateVrNo(string cFdName, string cTbName, string VrSeries, DateTime VrDate, string FldVrNo = "") { SqlCommand cmdForNewVrnoN = new SqlCommand(); SqlConnection con = new SqlConnection(); string DMLForNewVrno = ""; if (cFdName.Trim() == "" || VrSeries.Trim() == "") { return(""); } GBCCon GbcCon = new GBCCon(); string name = GbcCon.Database.Connection.Database; con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["GBCCon"].ToString(); con.Open(); cmdForNewVrnoN.Connection = con; cmdForNewVrnoN.CommandTimeout = 600; cmdForNewVrnoN.CommandType = CommandType.StoredProcedure; cmdForNewVrnoN.CommandText = "Pr_NewVrNoN"; cmdForNewVrnoN.Parameters.Add("@cFdName", SqlDbType.NVarChar, 5); cmdForNewVrnoN.Parameters.Add("@cTbName", SqlDbType.NVarChar, 50); cmdForNewVrnoN.Parameters.Add("@VrSeries", SqlDbType.NVarChar, 5); cmdForNewVrnoN.Parameters.Add("@VrLength", SqlDbType.Int, 5); cmdForNewVrnoN.Parameters.Add("@VrDate", SqlDbType.DateTime); cmdForNewVrnoN.Parameters.Add("@FldVrNo", SqlDbType.NVarChar, 50); cmdForNewVrnoN.Parameters.Add("@DbForVc ", SqlDbType.NVarChar, 50); cmdForNewVrnoN.Parameters.Add("@AcYr", SqlDbType.Int); cmdForNewVrnoN.Parameters.Add("@VrNoNew2", SqlDbType.NVarChar, 20); cmdForNewVrnoN.Parameters["@VrNoNew2"].Direction = ParameterDirection.Output; cmdForNewVrnoN.Parameters["@cFdName"].Value = cFdName; cmdForNewVrnoN.Parameters["@cTbName"].Value = cTbName; cmdForNewVrnoN.Parameters["@VrSeries"].Value = VrSeries; cmdForNewVrnoN.Parameters["@VrLength"].Value = System.Configuration.ConfigurationManager.AppSettings["VrLength"]; cmdForNewVrnoN.Parameters["@VrDate"].Value = VrDate; cmdForNewVrnoN.Parameters["@FldVrNo"].Value = FldVrNo; cmdForNewVrnoN.Parameters["@DbForVc "].Value = name + ".dbo.VC"; cmdForNewVrnoN.Parameters["@AcYr"].Value = ACYR(); cmdForNewVrnoN.ExecuteNonQuery(); DMLForNewVrno = cmdForNewVrnoN.Parameters["@VrNoNew2"].Value.ToString(); DMLForNewVrno = DMLForNewVrno.Trim(); cmdForNewVrnoN.Dispose(); con.Close(); return(DMLForNewVrno); }
public string SaveOrder(Order Ord, string FDNAME) { GBCCon gbc_con = new GBCCon(); Global objGlobal = new Global(); string name = gbc_con.Database.Connection.Database; //Get VrNo string vrno = GenrateVrNo(FDNAME, name + ".dbo.OB", (string.IsNullOrEmpty(Ord.series) ? "GC" : Ord.series), DateTime.Now.Date, "VRID"); double amt = 0.0; OB obj_ob = gbc_con.db_ob.SingleOrDefault(p => p.VrId == vrno); obj_ob.FromUserId = Ord.FromUserId; obj_ob.ToUserId = Ord.ToUserId; obj_ob.VrDate = DateTime.Now.Date; obj_ob.VrId = vrno; obj_ob.VrNo = Ord.VrNo; obj_ob.ImgName = Ord.ImgName; obj_ob.AppType = Ord.AppType; int i = 1; string isWQty = "0"; try { ServiceReg obj = gbc_con.db_SerReg.SingleOrDefault(p => p.Pcode == Ord.ToUserId); if (obj != null) { isWQty = obj.pretailordQty; } } catch { isWQty = "0"; } foreach (var item in Ord.oi) { string slno = "00" + i; i = i + 1; OI obj_oi = new OI(); obj_oi.Icode = item.Icode; obj_oi.IName = item.IName; obj_oi.MRP = item.MRP; obj_oi.OrdQty = item.Qty; obj_oi.FreeQty = item.Free; obj_oi.Packing = item.Packing; obj_oi.SlNo = slno.Substring(slno.Length - 3, 3); if (isWQty == "1") { obj_oi.Rate = item.WRate; obj_oi.Value = obj_oi.Rate * obj_oi.OrdQty; } else { obj_oi.Rate = item.Rate; obj_oi.Value = obj_oi.Rate * obj_oi.OrdQty; } obj_oi.VrId = vrno; amt = Convert.ToDouble(amt + obj_oi.Value); gbc_con.db_oi.Add(obj_oi); } amt = amt + Convert.ToDouble(Ord.DelCharges); //obj_ob.OrdAmt = amt; obj_ob.OrdAmt = Ord.OrdAmt; obj_ob.DelCharge = Convert.ToDouble(Ord.DelCharges); gbc_con.SaveChanges(); return(vrno); }