Пример #1
0
        public static bool Insert_SQMaster(SaleQuotMasterVM model)
        {
            DateTime recDate;

            try
            {
                if (model.SaleQuotCode == "" || model.SaleQuotCode == null)
                {
                    strAutoCode = sysfun.AutoGen("SaleQuotMaster", "SaleQuotCode", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("dd/MM/yyyy"), model.DealerCode);
                    //strAutoCode = sysfun.GetNewMaxID("ProdRecMaster", "RecNo", 8, "00166");
                    //recDate = DateTime.Parse( model.RecDate);
                }
                else
                {
                    strAutoCode = model.SaleQuotCode;
                    //string rec = sysfun.SaveDate( ).ToString();
                    //recDate = sysfun.SaveDate(model.BookRefDate);
                    //recDate = DateTime.Parse(rec);
                }
                SqlParameter[] param =
                {
                    new SqlParameter("@DealerCode", model.DealerCode),                      //0
                    new SqlParameter("@SaleQuotCode", strAutoCode),                         //1
                    new SqlParameter("@SaleQuotDate", sysfun.SaveDate(model.SaleQuotDate)), //2
                    new SqlParameter("@RefLetterNo", model.RefLetterNo),                    //3
                    new SqlParameter("@ValidDays", model.ValidDays),                        //4
                    new SqlParameter("@CustomerCode", model.CustomerCode),                  //5
                    new SqlParameter("@Subject", model.Subject),                            //6
                    new SqlParameter("@UpdUser", AuthBase.UserId),                          //7
                    new SqlParameter("@UpdTerm", General.CurrentIP),                        //8
                    new SqlParameter("@PaymentTerms", model.PaymentTerms),                  //9
                    new SqlParameter("@Exemption", model.Exemption),                        //10
                    new SqlParameter("@ForceJajeure", model.ForceJajeure),                  //11
                    new SqlParameter("@Warranty", model.Warranty),                          //12
                    new SqlParameter("@DocGST", model.DocGST),                              //13
                    new SqlParameter("@DocNTN", model.DocNTN),                              //14
                    new SqlParameter("@DocBrocher", model.DocBrocher),                      //15
                };

                if (ObjTrans.BeginTransaction(ref Trans) == true)
                {
                    sysfun.ExecuteSP_NonQuery("SP_Insert_SaleQuotMaster", param, Trans);


                    IsSaved = true;
                }
            }
            catch (Exception)
            {
                if (ObjTrans.BeginTransaction(ref Trans) == true)
                {
                    ObjTrans.RollBackTransaction(ref Trans);
                }

                throw;
            }

            return(IsSaved);
        }
        public JsonResult Insert_SQMaster(SaleQuotMasterVM SQMasterVM)
        {
            bool result = false;

            string msg = "Failed to save record..";

            result = SaleQuotMethods.Insert_SQMaster(SQMasterVM);

            if (result)
            {
                msg = "Successfully Added";
            }

            return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet));
        }