Пример #1
0
        public List <CustomOrderMaster> getOrderDetailByTicketID(int TicketID, int TenantID)
        {
            DataSet ds = new DataSet();
            List <CustomOrderMaster> objorderMaster = new List <CustomOrderMaster>();

            try
            {
                conn = Db.Connection;
                MySqlCommand cmd = new MySqlCommand("SP_GetOrderDetailByTicketID", conn);
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Ticket_ID", TicketID);
                cmd.Parameters.AddWithValue("@Tenant_ID", TenantID);
                MySqlDataAdapter da = new MySqlDataAdapter();
                da.SelectCommand = cmd;
                da.Fill(ds);

                if (ds != null && ds.Tables[0] != null)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        CustomOrderMaster customOrderMaster = new CustomOrderMaster();
                        customOrderMaster.OrderMasterID  = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderMasterID"]);
                        customOrderMaster.InvoiceNumber  = ds.Tables[0].Rows[i]["InvoiceNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["InvoiceNumber"]);
                        customOrderMaster.InvoiceDate    = Convert.ToDateTime(ds.Tables[0].Rows[i]["InvoiceDate"]);
                        customOrderMaster.OrdeItemPrice  = ds.Tables[0].Rows[i]["OrderPrice"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["OrderPrice"]);
                        customOrderMaster.OrderPricePaid = ds.Tables[0].Rows[i]["PricePaid"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["PricePaid"]);
                        customOrderMaster.DateFormat     = customOrderMaster.InvoiceDate.ToString("dd/MMM/yyyy");
                        customOrderMaster.StoreCode      = ds.Tables[0].Rows[i]["StoreCode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["StoreCode"]);
                        customOrderMaster.StoreAddress   = ds.Tables[0].Rows[i]["Address"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Address"]);
                        customOrderMaster.Discount       = ds.Tables[0].Rows[i]["Discount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["Discount"]);
                        int orderMasterId = Convert.ToInt32(ds.Tables[0].Rows[i]["OrderMasterID"]);
                        customOrderMaster.OrderItems = ds.Tables[1].AsEnumerable().Where(x => Convert.ToInt32(x.Field <int>("OrderMasterID")).
                                                                                         Equals(orderMasterId)).Select(x => new OrderItem()
                        {
                            OrderItemID   = Convert.ToInt32(x.Field <int>("OrderItemID")),
                            OrderMasterID = Convert.ToInt32(x.Field <int>("OrderMasterID")),
                            ArticleNumber = x.Field <object>("SKUNumber") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("SKUNumber")),
                            ArticleName   = x.Field <object>("SKUName") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("SKUName")),
                            ItemPrice     = x.Field <object>("ItemPrice") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("ItemPrice")),
                            PricePaid     = x.Field <object>("PricePaid") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("PricePaid")),
                            Discount      = x.Field <object>("Discount") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("Discount")),
                            RequireSize   = x.Field <object>("RequireSize") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("RequireSize"))
                        }).ToList();
                        customOrderMaster.ItemCount = customOrderMaster.OrderItems.Count();
                        customOrderMaster.ItemPrice = customOrderMaster.OrderItems.Sum(item => item.ItemPrice);
                        customOrderMaster.PricePaid = customOrderMaster.OrderItems.Sum(item => item.PricePaid);
                        objorderMaster.Add(customOrderMaster);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(objorderMaster);
        }
Пример #2
0
        /// <summary>
        /// Get Claim By ID
        /// </summary>
        /// <param name="claimID"></param>
        /// <param name="tenantID"></param>
        /// <param name="userID"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public CustomClaimByID GetClaimByID(int claimID, int tenantID, int userID, string url)
        {
            DataSet         ds = new DataSet();
            CustomClaimByID customClaimList = new CustomClaimByID();

            //List<CustomClaimList> lstCustomClaim = new List<CustomClaimList>();
            try
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("SP_GetClaimByID", conn);
                cmd.Connection = conn;
                cmd.Parameters.AddWithValue("@Claim_ID", claimID);
                cmd.Parameters.AddWithValue("@tenant_ID", tenantID);
                cmd.Parameters.AddWithValue("@user_ID", userID);
                cmd.CommandType = CommandType.StoredProcedure;
                MySqlDataAdapter da = new MySqlDataAdapter
                {
                    SelectCommand = cmd
                };
                da.Fill(ds);
                if (ds != null && ds.Tables[0] != null)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        customClaimList.ClaimID                 = ds.Tables[0].Rows[i]["ClaimID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["ClaimID"]);
                        customClaimList.Status                  = ds.Tables[0].Rows[i]["Status"] == DBNull.Value ? string.Empty : Convert.ToString((EnumMaster.ClaimStatus)Convert.ToInt32(ds.Tables[0].Rows[i]["Status"]));
                        customClaimList.AssigneeID              = ds.Tables[0].Rows[i]["AssigneeID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["AssigneeID"]);
                        customClaimList.AssignTo                = ds.Tables[0].Rows[i]["Assignto"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Assignto"]);
                        customClaimList.BrandID                 = ds.Tables[0].Rows[i]["BrandID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["BrandID"]);
                        customClaimList.BrandName               = ds.Tables[0].Rows[i]["BrandName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["BrandName"]);
                        customClaimList.CategoryID              = ds.Tables[0].Rows[i]["CategoryID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["CategoryID"]);
                        customClaimList.CategoryName            = ds.Tables[0].Rows[i]["CategoryName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["CategoryName"]);
                        customClaimList.SubCategoryID           = ds.Tables[0].Rows[i]["SubCategoryID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["SubCategoryID"]);
                        customClaimList.SubCategoryName         = ds.Tables[0].Rows[i]["SubCategoryName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["SubCategoryName"]);
                        customClaimList.IssueTypeID             = ds.Tables[0].Rows[i]["IssueTypeID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["IssueTypeID"]);
                        customClaimList.IssueTypeName           = ds.Tables[0].Rows[i]["IssueTypeName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["IssueTypeName"]);
                        customClaimList.CustomerID              = ds.Tables[0].Rows[i]["CustomerID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["CustomerID"]);
                        customClaimList.CustomerName            = ds.Tables[0].Rows[i]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["CustomerName"]);
                        customClaimList.CustomerPhoneNumber     = ds.Tables[0].Rows[i]["CustomerPhoneNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["CustomerPhoneNumber"]);
                        customClaimList.CustomerAlternateNumber = ds.Tables[0].Rows[i]["AltNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["AltNumber"]);
                        customClaimList.EmailID                 = ds.Tables[0].Rows[i]["CustomerEmailId"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["CustomerEmailId"]);
                        customClaimList.AlternateEmailID        = ds.Tables[0].Rows[i]["AltEmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["AltEmailID"]);
                        customClaimList.Gender                  = ds.Tables[0].Rows[i]["Gender"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["Gender"]);
                        customClaimList.ClaimAskFor             = ds.Tables[0].Rows[i]["ClaimPercent"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["ClaimPercent"]);
                        customClaimList.TargetClouserDate       = ds.Tables[0].Rows[i]["ClosureDate"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ClosureDate"]);
                        customClaimList.TicketID                = ds.Tables[0].Rows[i]["TicketID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["TicketID"]);
                        customClaimList.TicketingTaskID         = ds.Tables[0].Rows[i]["TicketingTaskID"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["TicketingTaskID"]);
                        customClaimList.Attachments             = ds.Tables[1].AsEnumerable().Select(x => new ClaimAttachment()
                        {
                            ClaimAttachmentId = Convert.ToInt32(x.Field <int>("ClaimAttachmentId")),
                            AttachmentName    = x.Field <object>("AttachmentName") == System.DBNull.Value || string.IsNullOrEmpty(Convert.ToString(x.Field <object>("AttachmentName"))) ? string.Empty : url + "/" + Convert.ToString(x.Field <object>("AttachmentName"))
                        }).ToList();

                        customClaimList.CommentByStores = ds.Tables[2].AsEnumerable().Select(x => new CommentByStore()
                        {
                            Name               = x.Field <object>("Name") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("Name")),
                            Comment            = x.Field <object>("Comment") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("Comment")),
                            CommentDate        = x.Field <object>("CommentDate") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("CommentDate")),
                            OldAgentID         = x.Field <object>("OldAgentID") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("OldAgentID")),
                            OldAgentName       = x.Field <object>("OldAgentName") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("OldAgentName")),
                            NewAgentID         = x.Field <object>("NewAgentID") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("NewAgentID")),
                            NewAgentName       = x.Field <object>("NewAgentName") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("NewAgentName")),
                            IsTicketingComment = x.Field <object>("iSTicketingComment") == DBNull.Value ? false : Convert.ToBoolean(x.Field <object>("iSTicketingComment"))
                        }).ToList();

                        customClaimList.CommentByApprovels = ds.Tables[3].AsEnumerable().Select(x => new CommentByApprovel()
                        {
                            Name            = x.Field <object>("Name") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("Name")),
                            Comment         = x.Field <object>("Comment") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("Comment")),
                            CommentDate     = x.Field <object>("CommentDate") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("CommentDate")),
                            IsRejectComment = x.Field <object>("IsRejectComment") == DBNull.Value ? false : Convert.ToBoolean(x.Field <object>("IsRejectComment")),
                        }).ToList();
                    }
                    if (ds != null && ds.Tables[4] != null)
                    {
                        for (int i = 0; i < ds.Tables[4].Rows.Count; i++)
                        {
                            {
                                CustomOrderMaster customOrderMaster = new CustomOrderMaster();

                                customOrderMaster.OrderMasterID   = Convert.ToInt32(ds.Tables[4].Rows[i]["OrderMasterID"]);
                                customOrderMaster.InvoiceNumber   = ds.Tables[4].Rows[i]["InvoiceNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[4].Rows[i]["InvoiceNumber"]);
                                customOrderMaster.InvoiceDate     = Convert.ToDateTime(ds.Tables[4].Rows[i]["InvoiceDate"]);
                                customOrderMaster.OrdeItemPrice   = ds.Tables[4].Rows[i]["OrderPrice"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[4].Rows[i]["OrderPrice"]);
                                customOrderMaster.OrderPricePaid  = ds.Tables[4].Rows[i]["PricePaid"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[4].Rows[i]["PricePaid"]);
                                customOrderMaster.DateFormat      = customOrderMaster.InvoiceDate.ToString("dd/MMM/yyyy");
                                customOrderMaster.StoreCode       = ds.Tables[4].Rows[i]["StoreCode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[4].Rows[i]["StoreCode"]);
                                customOrderMaster.StoreAddress    = ds.Tables[4].Rows[i]["Address"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[4].Rows[i]["Address"]);
                                customOrderMaster.Discount        = ds.Tables[4].Rows[i]["Discount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[4].Rows[i]["Discount"]);
                                customOrderMaster.PaymentModename = ds.Tables[4].Rows[i]["PaymentModename"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[4].Rows[i]["PaymentModename"]);
                                int orderMasterId = Convert.ToInt32(ds.Tables[4].Rows[i]["OrderMasterID"]);
                                customOrderMaster.OrderItems = ds.Tables[5].AsEnumerable().Where(x => Convert.ToInt32(x.Field <int>("OrderMasterID")).
                                                                                                 Equals(orderMasterId)).Select(x => new OrderItem()
                                {
                                    OrderItemID   = Convert.ToInt32(x.Field <int>("OrderItemID")),
                                    OrderMasterID = Convert.ToInt32(x.Field <int>("OrderMasterID")),
                                    ArticleNumber = x.Field <object>("SKUNumber") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("SKUNumber")),
                                    ArticleName   = x.Field <object>("SKUName") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("SKUName")),
                                    ItemPrice     = x.Field <object>("ItemPrice") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("ItemPrice")),
                                    PricePaid     = x.Field <object>("PricePaid") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("PricePaid")),
                                    Discount      = x.Field <object>("Discount") == DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("Discount")),
                                    RequireSize   = x.Field <object>("RequireSize") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("RequireSize")),
                                    PaymentMode   = x.Field <object>("PaymentMode") == DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("PaymentMode")),
                                }).ToList();
                                customOrderMaster.ItemCount       = customOrderMaster.OrderItems.Count();
                                customOrderMaster.ItemPrice       = customOrderMaster.OrderItems.Sum(item => item.ItemPrice);
                                customOrderMaster.PricePaid       = customOrderMaster.OrderItems.Sum(item => item.PricePaid);
                                customClaimList.CustomOrderMaster = customOrderMaster;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
                if (ds != null)
                {
                    ds.Dispose();
                }
            }
            return(customClaimList);
        }