コード例 #1
0
        public List <dynamic> SaveOrderRequest(CustRequest custreq)
        {
            var           OrderIDdet    = new List <dynamic>();
            SaveTempOrder SaveTempOrder = new SaveTempOrder();
            Order         ord           = new Order();

            if (!string.IsNullOrEmpty(custreq.OrderID))
            {
                ord.OrderId = Convert.ToInt64(securityHelper.Decrypt(custreq.OrderID, false));
            }
            else
            {
                ord.OrderId = 0;
            }


            if (!string.IsNullOrEmpty(custreq.BranchID))
            {
                ord.BranchId = Convert.ToInt64(custreq.BranchID);
            }
            else
            {
                ord.BranchId = 0;
            }
            if (!string.IsNullOrEmpty(custreq.SCity))
            {
                ord.CityId = Convert.ToInt64(custreq.SCity);
                //ord.CityId = 1;
            }
            else
            {
                ord.CityId = 0;
            }

            if (!string.IsNullOrEmpty(custreq.SCountry))
            {
                ord.CountryId = Convert.ToInt64(custreq.SCountry);
                //ord.CountryId = 1;
            }
            else
            {
                ord.CountryId = 0;
            }
            if (!string.IsNullOrEmpty(custreq.selectedCustomer))
            {
                ord.CustId = Convert.ToInt64(custreq.selectedCustomer);
            }
            else
            {
                ord.CustId = 0;
            }

            ord.Department = custreq.Department;
            if (!string.IsNullOrEmpty(custreq.DeliveryTo))
            {
                ord.IncoTermId = Convert.ToInt64(custreq.DeliveryTo);
            }
            else
            {
                ord.IncoTermId = 0;
            }
            ord.ContactName  = custreq.Sname;
            ord.ContactEmail = custreq.Semail;
            ord.ContactNum   = custreq.Sphone;

            ord.ReferenceNo     = custreq.Refernce;
            ord.BillingAddress  = (custreq.BAdd1 + "#" + custreq.BAdd2 + "#" + custreq.BAdd3 + "#" + custreq.BCityName + "#" + custreq.BState + "#" + custreq.BZip + "#" + custreq.BCountryName);
            ord.ShippingAddress = (custreq.SAdd1 + "#" + custreq.SAdd2 + "#" + custreq.SAdd3 + "#" + custreq.SCityName + "#" + custreq.SState + "#" + custreq.SZip + "#" + custreq.SCountryName);
            if (!string.IsNullOrEmpty(UserID))
            {
                ord.UserId = Convert.ToInt64(UserID);
            }


            int cstOrdr = SaveCustOrder(ord);

            SaveTempOrder.TempOrderID = ord.OrderId;
            if (SaveTempOrder.TempOrderID != 0)
            {
                if (!string.IsNullOrEmpty(custreq.ApproverDetails))
                {
                    var            Data            = JsonConvert.DeserializeObject <List <ApproverDetail> >(custreq.ApproverDetails);
                    ApproverDetail ApproverDetails = new ApproverDetail();
                    for (int i = 0; i < Data.Count; i++)
                    {
                        ApproverDetails = Data[i];
                        OrderApprover orda = new OrderApprover();
                        orda.OrderId = ord.OrderId;
                        orda.Serial  = i + 1; // Need to ask customer
                        orda.UserId  = ord.UserId;
                        if (ApproverDetails.AprName != null && ApproverDetails.AprEmail != null)
                        {
                            if (!string.IsNullOrEmpty(ApproverDetails.AprId))
                            {
                                orda.OAId = Convert.ToInt64(orda.OAId);
                            }

                            orda.ApproverName  = ApproverDetails.AprName;
                            orda.ApproverTitle = ApproverDetails.AprTitle;
                            orda.ApproverEmail = ApproverDetails.AprEmail;
                            orda.isLoggedin    = true; // Need to ask customer
                            orda.isApproved    = true; // Need to ask customer
                            int ordap = SaveCustOrderApprover(orda);
                        }
                    }
                }
            }

            OrderIDdet.Add(SaveTempOrder);
            OrderIDdet.Add(2);

            return(OrderIDdet);
        }
コード例 #2
0
        public int AddApprover(OrderApprover orderOrderApprover)
        {
            int orderAId = 0;
            // string insertProcedure = "[CreatOrderApprover]";
            string     insertProcedure = "[CreatOrderApproverTemp]";
            SqlCommand insertCommand   = new SqlCommand(insertProcedure, connection);

            insertCommand.CommandType = CommandType.StoredProcedure;
            if (orderOrderApprover.Serial != 0)
            {
                insertCommand.Parameters.AddWithValue("@Serial", orderOrderApprover.Serial);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Serial", 0);
            }

            if (orderOrderApprover.OrderId != 0)
            {
                insertCommand.Parameters.AddWithValue("@OrderId", orderOrderApprover.OrderId);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@OrderId", 0);
            }
            if (!string.IsNullOrEmpty(orderOrderApprover.ApproverName))
            {
                insertCommand.Parameters.AddWithValue("@ApproverName", orderOrderApprover.ApproverName);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@ApproverName", DBNull.Value);
            }

            if (!string.IsNullOrEmpty(orderOrderApprover.ApproverTitle))
            {
                insertCommand.Parameters.AddWithValue("@ApproverTitle", orderOrderApprover.ApproverTitle);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@ApproverTitle", DBNull.Value);
            }


            if (!string.IsNullOrEmpty(orderOrderApprover.ApproverEmail))
            {
                insertCommand.Parameters.AddWithValue("@ApproverEmail", orderOrderApprover.ApproverEmail);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@ApproverEmail", DBNull.Value);
            }

            if (orderOrderApprover.UserId != 0)
            {
                insertCommand.Parameters.AddWithValue("@UserId", orderOrderApprover.UserId);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@UserId", 0);
            }
            if (!string.IsNullOrEmpty(orderOrderApprover.Comments))
            {
                insertCommand.Parameters.AddWithValue("@Comments", orderOrderApprover.Comments);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@Comments", DBNull.Value);
            }


            if (orderOrderApprover.isLoggedin != false)
            {
                insertCommand.Parameters.AddWithValue("@isLoggedin", orderOrderApprover.isLoggedin);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@isLoggedin", 0);
            }

            if (orderOrderApprover.isApproved != false)
            {
                insertCommand.Parameters.AddWithValue("@isApproved", orderOrderApprover.isApproved);
            }
            else
            {
                insertCommand.Parameters.AddWithValue("@isApproved", 0);
            }

            insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
            insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;

            insertCommand.Parameters.Add("@OAIdout", System.Data.SqlDbType.Int);
            insertCommand.Parameters["@OAIdout"].Direction = ParameterDirection.Output;


            try
            {
                connection.Open();
                insertCommand.ExecuteNonQuery();
                int count = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value);
                orderAId = System.Convert.ToInt32(insertCommand.Parameters["@OAIdout"].Value);


                return(orderAId);
            }
            catch (Exception ex)
            {
                log.logErrorMessage("OrderData.AddApprover");
                log.logErrorMessage(ex.StackTrace);
                return(orderAId);
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #3
0
        private int SaveCustOrderApprover(OrderApprover ordapp)
        {
            int    OrderId         = 0;
            int    count           = 0;
            string updateProcedure = "[UpdateOrderApprover]";

            SqlCommand updateCommand = new SqlCommand(updateProcedure, connection);

            updateCommand.CommandType = CommandType.StoredProcedure;
            if (ordapp.OAId != 0)
            {
                updateCommand.Parameters.AddWithValue("@OAId", ordapp.OAId);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OAId", 0);
            }
            if (ordapp.OrderId != 0)
            {
                updateCommand.Parameters.AddWithValue("@OrderId", ordapp.OrderId);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@OrderId", 0);
            }


            if (ordapp.Serial != 0)
            {
                updateCommand.Parameters.AddWithValue("@Serial ", ordapp.Serial);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@Serial ", 0);
            }
            if (!string.IsNullOrEmpty(ordapp.ApproverName))
            {
                updateCommand.Parameters.AddWithValue("@ApproverName", ordapp.ApproverName);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@ApproverName", DBNull.Value);
            }
            if (!string.IsNullOrEmpty(ordapp.ApproverTitle))
            {
                updateCommand.Parameters.AddWithValue("@ApproverTitle", ordapp.ApproverTitle);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@ApproverTitle", DBNull.Value);
            }
            if (!string.IsNullOrEmpty(ordapp.ApproverEmail))
            {
                updateCommand.Parameters.AddWithValue("@ApproverEmail", ordapp.ApproverEmail);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@ApproverEmail", DBNull.Value);
            }

            if (ordapp.UserId != 0)
            {
                updateCommand.Parameters.AddWithValue("@UserId", ordapp.UserId);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@UserId", 0);
            }

            if (!string.IsNullOrEmpty(ordapp.Comments))
            {
                updateCommand.Parameters.AddWithValue("@Comments", ordapp.Comments);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@Comments", DBNull.Value);
            }
            if (ordapp.isLoggedin)
            {
                updateCommand.Parameters.AddWithValue("@isLoggedin", ordapp.isLoggedin);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@isLoggedin", 0);
            }

            if (ordapp.isApproved)
            {
                updateCommand.Parameters.AddWithValue("@isApproved", ordapp.isApproved);
            }
            else
            {
                updateCommand.Parameters.AddWithValue("@isApproved", 0);
            }

            updateCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int);
            updateCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output;


            try
            {
                connection.Open();
                updateCommand.ExecuteNonQuery();
                if (updateCommand.Parameters["@ReturnValue"].Value != DBNull.Value)
                {
                    count = System.Convert.ToInt32(updateCommand.Parameters["@ReturnValue"].Value);
                }



                return(count);
            }
            catch (Exception ex)
            {
                log.logErrorMessage("");
                log.logErrorMessage(ex.StackTrace);
                return(count);
            }
            finally
            {
                connection.Close();
            }
        }