/// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public bool ValidateUpdateProduct(b2bHotFeaProduct data)
 {
     try
     {
         b2bHotFeaProduct model = qDB.b2bHotFeaProducts.Single(q => q.ProductID == data.ProductID);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool SaveHotFeat(List <int> CompID, List <int> Expire, List <int> ProductID, List <string> Status, List <string> HotPrice, string CompCode)
 {
     using (var trans = new TransactionScope())
     {
         CountSuccess = 0;
         var i = 0;
         foreach (var it in ProductID)
         {
             if (CheckExistProductInHotFeat(Status[i], (int)it))
             {
                 var data = new b2bHotFeaProduct();
                 data.ProductID     = (int)it;
                 data.CompID        = CompID[i];
                 data.ActivatedDate = DateTimeNow;
                 data.ExpiredDate   = DateTime.Now.AddMonths((int)Expire[i]);
                 data.Status        = Status[i].ToString().ToUpper();
                 data.HotPrice      = Convert.ToDecimal(HotPrice[i]);
                 data.IsShow        = true;
                 data.IsDelete      = false;
                 data.RowFlag       = 3;
                 data.ModifiedBy    = CompCode;
                 data.CreatedBy     = CompCode;
                 data.PackageCount  = 1;
                 data.CreatedDate   = DateTimeNow;
                 data.ModifiedDate  = DateTimeNow;
                 data.RowVersion    = 1;
                 qDB.b2bHotFeaProducts.InsertOnSubmit(data);
                 qDB.SubmitChanges();
                 CountSuccess++;
             }
             i++;
         }
         trans.Complete();
         IsResult = true;
     }
     return(IsResult);
 }
Пример #3
0
        public bool ApproveOrderPackage(List <int> OrderID, string CompCode)
        {
            using (var trans = new TransactionScope())
            {
                for (var i = 0; i < OrderID.Count(); i++)
                {
                    UpdateByCondition <b2bOrder>("OrderStatus = N'A' , ApproveDate = N'" + DateTimeNow + "' , modifiedby = N'" + CompCode + "'", "OrderID = " + OrderID[i]);

                    var Details = SelectData <view_OrderDetail>(" * ", " IsDelete  = 0 AND OrderID = " + OrderID[i]);
                    for (var j = 0; j < Details.Count(); j++)
                    {
                        DateTime date = new DateTime();
                        if (Details[j].ODDuration > 0)
                        {
                            date = DateTime.Now.AddDays((int)Details[j].ODDuration);
                        }
                        else
                        {
                            TimeSpan time = new TimeSpan(2020, 12, 31);
                            date.Add(time);
                        }
                        UpdateByCondition <b2bOrderDetail>("StartDate = N'" + DateTimeNow + "' , ExpiredDate = N'" + date + "' , modifiedby = N'" + CompCode + "'", "OrderDetailID = " + Details[j].OrderDetailID);

                        if (Details[j].PackageID >= 26 && Details[j].PackageID <= 28)
                        {
                            var HotFeat = SelectData <b2bHotFeaProduct>(" * ", "OrderDetailID = " + Details[j].OrderDetailID);
                            if (HotFeat.Count() > 0)
                            {
                                UpdateByCondition <b2bHotFeaProduct>("IsDelete  = 0", "OrderDetailID = " + Details[j].OrderDetailID);
                            }
                            else
                            {
                                var data = new b2bHotFeaProduct();
                                data.OrderDetailID = Details[j].OrderDetailID;
                                data.CompID        = Details[j].CompID;
                                data.ActivatedDate = DateTimeNow;
                                data.ExpiredDate   = date;
                                if (Details[j].PackageID == 26)
                                {
                                    data.Status = "F";
                                }
                                else if (Details[j].PackageID == 27)
                                {
                                    data.Status = "H";
                                }
                                else if (Details[j].PackageID == 28)
                                {
                                    data.Status = "P";
                                }
                                data.HotPrice     = Convert.ToDecimal(Details[j].PackagePrice);
                                data.IsShow       = true;
                                data.IsDelete     = false;
                                data.RowFlag      = 3;
                                data.ModifiedBy   = CompCode;
                                data.CreatedBy    = CompCode;
                                data.PackageCount = 1;
                                data.CreatedDate  = DateTimeNow;
                                data.ModifiedDate = DateTimeNow;
                                data.RowVersion   = 1;
                                qDB.b2bHotFeaProducts.InsertOnSubmit(data);
                                qDB.SubmitChanges();
                            }
                        }
                    }
                }
                trans.Complete();
                return(IsResult);
            }
        }