Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="purchaseOrderDetails">the order details</param>
        /// <param name="customerEmailSettingName">the name of the email to use the customer should see</param>
        /// <param name="emailSender">the email address that should be listed as the sender</param>
        /// <param name="websiteTitle">The name of the website sending the email</param>
        /// <returns></returns>
        public static bool SendOrderShippedEmail(PurchaseOrderDetails purchaseOrderDetails, string customerEmailSettingName, string emailSender, string websiteTitle)
        {
            string EmailsSent = string.Empty;

            try
            {
                Dictionary <string, string> ValuesToReplace = new Dictionary <string, string>();

                ValuesToReplace.Add("[WEBSITE_TITLE]", websiteTitle);
                ValuesToReplace.Add("[FIRSTNAME]", purchaseOrderDetails.PayPalOrderDetails.CustomerInfo.FirstName);
                ValuesToReplace.Add("[LASTNAME]", purchaseOrderDetails.PayPalOrderDetails.CustomerInfo.LastName);
                ValuesToReplace.Add("[ORDER_CONFIRM_NUMBER]", purchaseOrderDetails.Id);
                ValuesToReplace.Add("[ORDER_DATE]", purchaseOrderDetails.PayPalOrderDetails.OrderPlacedDateUtc.ToString("g") + " UTC");
                ValuesToReplace.Add("[ORDER_DETAILS_TABLE]", GenerateOrderDetailsTable(purchaseOrderDetails));
                ValuesToReplace.Add("[SELECTED SHIPPING METHOD]", "<br/><br/>Your order is being shipped by: " + purchaseOrderDetails.PayPalOrderDetails.ShippingMethodType);

                string TrackingLink = CompanyCommons.PhysicalShipping.GenerateTrackingLink(purchaseOrderDetails.PayPalOrderDetails.ShippingMethodType, purchaseOrderDetails.PayPalOrderDetails.ShippingTrackingNumber);

                if (!string.IsNullOrWhiteSpace(TrackingLink))
                {
                    TrackingLink = "<br/><br/>Click the link below to view shipping progress:<br/><br/><a href=\"" + TrackingLink + "\">" + TrackingLink + "</a>";
                }

                ValuesToReplace.Add("[TRACKING_NUMBER]", "<br/><br/>Tracking Number: " + purchaseOrderDetails.PayPalOrderDetails.ShippingTrackingNumber + TrackingLink);

                CompanyCommons.Email.SendEmailBasedOnFile("CustomerOrderShipped_" + customerEmailSettingName + ".html", purchaseOrderDetails.PayPalOrderDetails.CustomerInfo.Email, emailSender, ValuesToReplace, null, EMAIL_MODULE_NAME);
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Emails.Ecommerce.SendNewEcommerceEmails() Unable to send emails: " + e.Message);
            }

            return(string.IsNullOrWhiteSpace(EmailsSent));
        }
Пример #2
0
        /// <summary>
        /// After a new purchase order is final and saved, we need to substract the stock levels from the actual product.
        /// </summary>
        /// <param name="purchOrder"></param>
        public static void ProcessNewOrderStockLevels(SettingGroup paypalSettings, PurchaseOrderDetails purchOrder)
        {
            try
            {
                if (purchOrder != null && purchOrder.PurchasedProductList != null && purchOrder.PurchasedProductList.Count > 0)
                {
                    foreach (var PurchProd in purchOrder.PurchasedProductList)
                    {
                        Product Prod = ProductDAO.LoadByBsonId(PurchProd.Id);

                        if (Prod != null)
                        {
                            Prod.UpdateStock(PurchProd);

                            ProductDAO.Save(Prod);

                            Chimera.Core.Notifications.ProductStock.ProcessPurchasedProduct(paypalSettings, Prod);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.PurchaseOrders.ProductStock.ProcessNewOrderStockLevels()" + e.Message);
            }
        }
Пример #3
0
        private void AddPurchaseOrder()
        {
            var temp = new NewRFQ_PurchaseOrderCreationChildViewModel();

            Client.SearchRFQItemsFORPOAsync("", null, null);

            Client.SearchRFQItemsFORPOCompleted += (ss, ee)
                                                   =>
            {
                foreach (var rfqSubHeader in ee.Result)
                {
                    temp.RFQHeaderList.Add(rfqSubHeader);
                }
                temp.SubmitSelectedStyles += (s, e) =>
                {
                    ParentId = TransID;
                    var purchaseOrderCreationChildViewModel = s as NewRFQ_PurchaseOrderCreationChildViewModel;
                    if (purchaseOrderCreationChildViewModel == null)
                    {
                        return;
                    }
                    foreach (var item in purchaseOrderCreationChildViewModel.SelectedStyles)
                    {
                        PurchaseOrderDetails.Add(new NewRfqPurchasOrderDetailsViewModel
                        {
                            StyleHeader = item.StyleCode,
                            RowTotal    = item.Qty,
                            StyleColor  = item.ColorCode,
                            Price       = (decimal)item.Cost
                        });
                    }
                };
                temp.InitiateSearch();
            };
        }
        public void CreatePurchaseOrder(string userId, string supplierId)
        {
            List <PurchaseCart> cartList         = dbcontext.purchaseCarts.Where(x => x.EmployeeId == userId).ToList();
            Employee            emp              = deptService.findEmployeeById(userId);
            PurchaseOrder       newPurchaseOrder = new PurchaseOrder();

            newPurchaseOrder.Id         = Guid.NewGuid().ToString();
            newPurchaseOrder.EmployeeId = emp.Id;
            newPurchaseOrder.Employee   = emp;
            newPurchaseOrder.status     = POStatus.PENDING;
            newPurchaseOrder.date       = DateTime.Now;
            newPurchaseOrder.SupplierId = supplierId;
            foreach (var i in cartList)
            {
                Inventory            inv = dbcontext.inventories.Where(x => x.Id == i.Id).FirstOrDefault();
                PurchaseOrderDetails purchaseOrderDetail = new PurchaseOrderDetails();
                purchaseOrderDetail.Id = Guid.NewGuid().ToString();
                purchaseOrderDetail.PurchaseOrderId = newPurchaseOrder.Id;
                purchaseOrderDetail.Inventory       = i.Inventory;
                purchaseOrderDetail.InventoryId     = i.InventoryId;
                purchaseOrderDetail.quantity        = i.Qty;
                dbcontext.Add(purchaseOrderDetail);
            }
            dbcontext.Add(newPurchaseOrder);
            dbcontext.purchaseCarts.RemoveRange(cartList);
            dbcontext.SaveChanges();
        }
Пример #5
0
        public void clbOrderNumbers_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            PurchaseOrdersObj purchaseorder = PurchaseOrders.GetByID((int)clbOrderNumbers.Items[e.Index]);

            if (e.NewValue == CheckState.Checked)
            {
                foreach (PurchaseOrderDetailsObj item in PurchaseOrderDetails.GetByPONumber(purchaseorder.PONumber).FindAll(m => m.QuantityRemaining != 0))
                {
                    bs.Add(item);
                }
                foreach (POHistoryobj  item in POHistory.GetReceivedItems(purchaseorder.PONumber))
                {
                    rbs.Add(item);
                }
                foreach (POLogObj item in POLog.GetAll(Convert.ToInt32(cbSupplier.SelectedValue),purchaseorder.PONumber).FindAll(m=>m.IsUpdated == false))
                {
                    nbs.Add(item);
                }
            }
            else
            {
                foreach (PurchaseOrderDetailsObj item in purchaseorderdetailslist.FindAll(m => m.PONumber == purchaseorder.PONumber))
                {
                    bs.Remove(item);
                }
                foreach (POHistoryobj item in ReceivingList.FindAll(m => m.PONumber == purchaseorder.PONumber))
                {
                    rbs.Remove(item);
                }
                foreach (POLogObj  item in NotReceivingList.FindAll(m => m.PONumber == purchaseorder.PONumber))
                {
                   nbs.Remove(item); 
                }
            }
        }
Пример #6
0
        public static List <PurchaseOrderDetails> GetOrderDetailsBySupplier()
        {
            List <PurchaseOrderDetails> pos = new List <PurchaseOrderDetails>();

            using (SqlConnection conn = new SqlConnection(Data.db_cfg))
            {
                conn.Open();

                string     q   = @"SELECT MONTH(orderDate) as monthOfOrder, YEAR(orderDate) as yearOfOrder,sum(quantity) as total, po.supplierId,itemId,name as supplierName from PurchaseOrder po, PurchaseOrderDetails pod, Supplier s WHERE po.orderId = pod.orderId AND po.supplierId = s.supplierId AND STATUS='CLOSED'
                            GROUP BY MONTH(orderDate), YEAR(orderDate), po.supplierId, itemId,name";
                SqlCommand cmd = new SqlCommand(q, conn);

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    PurchaseOrderDetails po = new PurchaseOrderDetails()
                    {
                        MonthOfOrder = (int)reader["monthOfOrder"],
                        YearOfOrder  = (int)reader["yearOfOrder"],
                        Quantity     = (int)reader["total"],
                        SupplierId   = (long)reader["supplierId"],
                        SupplierName = (string)reader["supplierName"],
                        ItemId       = (long)reader["itemId"]
                    };
                    pos.Add(po);
                }
                return(pos);
            }
        }
Пример #7
0
        /// <summary>
        /// Called when the purchase order payment is captured, we want to update the notification description and created date
        /// </summary>
        /// <param name="purchOrder"></param>
        /// <returns></returns>
        public static bool ProcessPurchaseOrderPaymentCaptured(PurchaseOrderDetails purchOrder)
        {
            try
            {
                Notification Notif = DashboardNotificationDAO.Load(purchOrder.Id);

                string UpdateText = String.Format("Purchase order shipment needs updated in order to notify customer.   Order placed on {0} UTC with a total of {1} spent.", purchOrder.PayPalOrderDetails.OrderPlacedDateUtc.ToString("g"), (purchOrder.PayPalOrderDetails.BaseAmount + purchOrder.PayPalOrderDetails.TaxAmount + purchOrder.PayPalOrderDetails.ShippingAmount).ToString("C"));

                //arleady exists
                if (Notif != null && !string.IsNullOrWhiteSpace(Notif.Id))
                {
                    return(DashboardNotificationDAO.Update(purchOrder.Id, UpdateText));
                }
                //else save a new one
                else
                {
                    Notification NewNotification = GenerateNewNotification(purchOrder.Id, UpdateText);

                    return(DashboardNotificationDAO.Save(NewNotification));
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.Notifications.PurchaseOrder.ProcessPurchaseOrderPaymentCaptured()" + e.Message);
            }

            return(false);
        }
Пример #8
0
        private void save_Click(object sender, EventArgs e)
        {
            // 得到详细的采购信息
            ArrayList dataList = getPurchaseOrderDetailsValue();

            if (dataList.Count > 0)
            {
                // 采购订单表头和表尾信息
                PurchaseOrderTable record = getPurchaseOrderValue();
                if (purchaseOrderIsFull(record) && purchaseOrderDetailsIsFull(dataList))
                {
                    PurchaseOrder.getInctance().insert(record, false);
                    PurchaseOrderDetails.getInctance().insert(dataList);
                    BillNumber.getInctance().inserBillNumber(BillTypeNumber, this.labelTradingDate.Text, this.labelBillNumber.Text.ToString());

                    if (m_billNumber.Length == 0)
                    {
                        MessageBoxExtend.messageOK("数据保存成功");
                    }

                    this.Close();
                }
            }
            else
            {
                MessageBoxExtend.messageWarning("此单据不包含任何交易信息,单据保存失败.");
            }
        }
    public static List <PurchaseOrderDetails> GetAll()
    {
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = DBConnection.CONNECTION_STRING;
            conn.Open();

            string sql = "SELECT PurchaseOrderDetails_Id, Purchase_Order_Number, Product, Quantity, Unit_Price, Extended_Price "
                         + "FROM PurchaseOrderDetails ";

            SqlCommand command = new SqlCommand(sql, conn);
            using (SqlDataReader reader = command.ExecuteReader())
            {
                List <PurchaseOrderDetails> podList = new List <PurchaseOrderDetails>();

                while (reader.Read())
                {
                    PurchaseOrderDetails pod = new PurchaseOrderDetails(reader.GetInt32(0),
                                                                        reader.GetInt32(1),
                                                                        reader.GetString(2),
                                                                        reader.GetInt32(3),
                                                                        reader.GetDouble(4),
                                                                        reader.GetDouble(5));
                    podList.Add(pod);
                }

                return(podList);
            }
        }
    }
Пример #10
0
        public PurchaseOrderDetails GetsByString(string sString)
        {
            PurchaseOrderDetails oPurchaseOrderDetails = new PurchaseOrderDetails();

            try
            {
                SqlCommand cmd = new SqlCommand(sString, _conn);

                cmd.CommandType = CommandType.Text;
                //cmd.Parameters.Add(new SqlParameter("@PPID", SqlDbType.VarChar)).Value = sString;
                if (_conn.State == ConnectionState.Open)
                {
                }
                else
                {
                    cmd.Connection.Open();
                }
                IDataReader reader = cmd.ExecuteReader();

                oPurchaseOrderDetails = CreateObjects(reader);
                reader.Close();
                cmd.Dispose();
                cmd.Connection.Close();
            }
            catch (Exception e)
            {
                throw new ServiceException(e.Message, e);
            }
            return(oPurchaseOrderDetails);
        }
Пример #11
0
        private void btnCreatePO_Click(object sender, EventArgs e)
        {
            List <SupplierObj> Suppliers = (dgvSupplier.DataSource as List <SupplierObj>).FindAll(x => x.Isordered == true);

            if (Suppliers.Count == 0)
            {
                MessageBox.Show("there is no Purchases order to created");
                return;
            }
            List <InventoryRecord> InventoryRecords = (dgvItems.DataSource as List <InventoryRecord>).FindAll(x => x.ISordered == true);

            foreach (SupplierObj Supplier in Suppliers)
            {
                List <InventoryRecord> InventoryRecordsToinsert = InventoryRecords.FindAll(x => x.SupplierID == Supplier.SupplierID.ToString());
                int i = 1;
                PurchaseOrders.Insert(Supplier, "WithoutSend Mail", dtpDue.Value, InventoryRecordsToinsert.Sum(x => x.Cost));
                foreach (InventoryRecord inventoryrecord in InventoryRecordsToinsert)
                {
                    inventoryrecord.Cost         = inventoryrecord.HideCost * inventoryrecord.QtyToOrder;
                    inventoryrecord.ExtendedCost = inventoryrecord.HideCost * inventoryrecord.QtyToOrder;
                    inventoryrecord.IsAuto       = IsAuto;
                    PurchaseOrderDetails.Insert(inventoryrecord, i, dtpExpected.Value);
                    POHistory.Insert(inventoryrecord, i, txtCancel.Text);
                    Inventory.AddToLogAccDB(inventoryrecord);
                    i++;
                }
            }
            MessageBox.Show("purchase order created successfully");
            this.Close();
        }
Пример #12
0
        public PurchaseOrderDetails GetsByID(string nID, string nlotNumber)
        {
            PurchaseOrderDetails oPurchaseOrderDetails = new PurchaseOrderDetails();

            try
            {
                SqlCommand cmd = new SqlCommand("SP_PurchaseOrderDetail_GetsByID", _conn);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@PONumber", SqlDbType.NVarChar)).Value  = nID;
                cmd.Parameters.Add(new SqlParameter("@lotNumber", SqlDbType.NVarChar)).Value = nlotNumber;
                if (_conn.State == ConnectionState.Open)
                {
                }
                else
                {
                    cmd.Connection.Open();
                }
                IDataReader reader = cmd.ExecuteReader();

                oPurchaseOrderDetails = CreateObjects(reader);
                reader.Close();
                cmd.Dispose();
                cmd.Connection.Close();
            }
            catch (Exception e)
            {
                throw new ServiceException(e.Message, e);
            }
            return(oPurchaseOrderDetails);
        }
Пример #13
0
        public PurchaseOrderDetails Gets()
        {
            PurchaseOrderDetails oPurchaseOrderDetails = new PurchaseOrderDetails();

            try
            {
                SqlCommand cmd = new SqlCommand("SP_PurchaseOrderDetail_Gets", _conn);

                cmd.CommandType = CommandType.StoredProcedure;
                if (_conn.State == ConnectionState.Open)
                {
                }
                else
                {
                    cmd.Connection.Open();
                }
                IDataReader reader = cmd.ExecuteReader();

                oPurchaseOrderDetails = CreateObjects(reader);
                reader.Close();
                cmd.Dispose();
                cmd.Connection.Close();
            }
            catch (Exception e)
            {
                throw new ServiceException(e.Message, e);
            }
            return(oPurchaseOrderDetails);
        }
    public static PurchaseOrderDetails Get(int Purchase_Order_Number)
    {
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = DBConnection.CONNECTION_STRING;
            conn.Open();

            string sql = "SELECT PurchaseOrderDetails_Id, Purchase_Order_Number, Product, Quantity, Unit_Price, Extended_Price "
                         + "FROM PurchaseOrderDetails "
                         + "WHERE Purchase_Order_Number = @Purchase_Order_Number";

            SqlCommand command = new SqlCommand(sql, conn);
            command.Parameters.AddWithValue("Purchase_Order_Number", Purchase_Order_Number);

            using (SqlDataReader reader = command.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    reader.Read();

                    PurchaseOrderDetails pod = new PurchaseOrderDetails(reader.GetInt32(0),
                                                                        reader.GetInt32(1),
                                                                        reader.GetString(2),
                                                                        reader.GetInt32(3),
                                                                        reader.GetDouble(4),
                                                                        reader.GetDouble(5));
                    return(pod);
                }
                else
                {
                    return(null);
                }
            }
        }
    }
Пример #15
0
        private void writeBillDetailsInfoFromBillNumber(string billNumber)
        {
            // DataGridView 赋值
            SortedDictionary <int, PurchaseOrderDetailsTable> purchaseOrderDetails =
                PurchaseOrderDetails.getInctance().getPurchaseInfoFromBillNumber(billNumber);

            foreach (KeyValuePair <int, PurchaseOrderDetailsTable> index in purchaseOrderDetails)
            {
                PurchaseOrderDetailsTable record = new PurchaseOrderDetailsTable();
                record = index.Value;

                int rowIndex = Convert.ToInt32(record.rowNumber.ToString()) - 1;

                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.MatetielNumber].Value     = record.materielID;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.MatetielName].Value       = record.materielName;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.Model].Value              = record.materielModel;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.Brand].Value              = record.brand;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.Unit].Value               = record.materielUnitPurchase;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.Price].Value              = record.price;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.Value].Value              = record.value;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.Turnover].Value           = record.sumMoney;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.TransportationCost].Value = record.transportationCost;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.OtherCost].Value          = record.otherCost;
                dataGridViewDataList.Rows[rowIndex].Cells[(int)DataGridColumnName.SumTurnover].Value        = record.totalMoney;
            }
        }
Пример #16
0
        public static List <PurchaseOrderDetails> GetItemsInPurchaseOrder(long orderId)
        {
            List <PurchaseOrderDetails> items = new List <PurchaseOrderDetails>();

            using (SqlConnection conn = new SqlConnection(Data.db_cfg))
            {
                conn.Open();

                string     q   = @"SELECT * from PurchaseOrderDetails WHERE orderId = '" + orderId + "'";
                SqlCommand cmd = new SqlCommand(q, conn);

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    PurchaseOrderDetails item = new PurchaseOrderDetails()
                    {
                        OrderId  = (long)reader["orderId"],
                        ItemId   = (long)reader["itemId"],
                        Quantity = (int)reader["quantity"]
                    };
                    items.Add(item);
                }
            }
            foreach (var item in items)
            {
                item.Item = new Inventory();
                item.Item.ItemSuppliersDetails = new PriceList();
            }
            return(items);
        }
Пример #17
0
 PurchaseOrderViewModel BuildPurchaseOrderViewModel(PurchaseOrderDetails purchaseOrder)
 {
     return(new PurchaseOrderViewModel
     {
         PONumber = purchaseOrder == null
                                 ? string.Empty
                                 : purchaseOrder.Number
     });
 }
Пример #18
0
        public PurchaseOrderDetails  SelectById(Int64 opid)
        {
            SqlDataAdapter       da;
            DataSet              ds = new DataSet();
            PurchaseOrderDetails objorderproducts = new PurchaseOrderDetails();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "PurchaseOrderDetails_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@opid", opid);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                objorderproducts.opid = Convert.ToInt64(ds.Tables[0].Rows[0]["opid"]);
                                objorderproducts.oid  = Convert.ToInt64(ds.Tables[0].Rows[0]["oid"]);
                                objorderproducts.uid  = Convert.ToInt64(ds.Tables[0].Rows[0]["uid"]);
                                objorderproducts.pid  = Convert.ToInt64(ds.Tables[0].Rows[0]["pid"]);
                                objorderproducts.qty  = Convert.ToInt64(ds.Tables[0].Rows[0]["qty"]);

                                objorderproducts.rate       = Convert.ToDecimal(ds.Tables[0].Rows[0]["rate"]);
                                objorderproducts.subtotal   = Convert.ToDecimal(ds.Tables[0].Rows[0]["subtotal"]);
                                objorderproducts.discount   = Convert.ToDecimal(ds.Tables[0].Rows[0]["discount"]);
                                objorderproducts.scheme     = Convert.ToDecimal(ds.Tables[0].Rows[0]["scheme"]);
                                objorderproducts.frieghtamt = Convert.ToDecimal(ds.Tables[0].Rows[0]["frieghtamt"]);

                                objorderproducts.igstper = Convert.ToDecimal(ds.Tables[0].Rows[0]["igstper"]);
                                objorderproducts.gstamt  = Convert.ToDecimal(ds.Tables[0].Rows[0]["gstamt"]);
                                objorderproducts.total   = Convert.ToDecimal(ds.Tables[0].Rows[0]["total"]);
                                objorderproducts.netrate = Convert.ToDecimal(ds.Tables[0].Rows[0]["netrate"]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objorderproducts);
        }
Пример #19
0
        private PurchaseOrderDetails CreateObjects(IDataReader oReader)
        {
            PurchaseOrderDetails oPurchaseOrderDetails = new PurchaseOrderDetails();
            NullHandler          oHandler = new NullHandler(oReader);

            while (oReader.Read())
            {
                PurchaseOrderDetail oItem = CreateObject(oHandler);
                oPurchaseOrderDetails.Add(oItem);
            }
            return(oPurchaseOrderDetails);
        }
Пример #20
0
        public Int64 Insert(PurchaseOrderDetails objorderproducts)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "PurchaseOrderDetails_Insert";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@opid";
                param.Value         = objorderproducts.opid;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@oid", objorderproducts.oid);
                cmd.Parameters.AddWithValue("@uid", objorderproducts.uid);
                cmd.Parameters.AddWithValue("@pid", objorderproducts.pid);
                cmd.Parameters.AddWithValue("@qty", objorderproducts.qty);
                cmd.Parameters.AddWithValue("@rate", objorderproducts.rate);


                cmd.Parameters.AddWithValue("@subtotal", objorderproducts.subtotal);
                cmd.Parameters.AddWithValue("@discount", objorderproducts.discount);
                cmd.Parameters.AddWithValue("@scheme", objorderproducts.scheme);

                cmd.Parameters.AddWithValue("@frieghtamt", objorderproducts.frieghtamt);
                cmd.Parameters.AddWithValue("@taxableamt", objorderproducts.taxableamt);
                cmd.Parameters.AddWithValue("@csgtper", objorderproducts.csgtper);
                cmd.Parameters.AddWithValue("@sgstper", objorderproducts.sgstper);
                cmd.Parameters.AddWithValue("@igstper", objorderproducts.igstper);
                cmd.Parameters.AddWithValue("@netrate", objorderproducts.netrate);
                cmd.Parameters.AddWithValue("@gstamt", objorderproducts.gstamt);
                cmd.Parameters.AddWithValue("@total", objorderproducts.total);


                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
Пример #21
0
        /// <summary>
        /// Saves the order detail.
        /// </summary>
        /// <param name="header">The header.</param>
        private void SaveOrderDetail(PurchaseOrderHeader header)
        {
            foreach (DataGridViewRow rows in this.dgvDetailsList.Rows)
            {
                bool result = true;

                //// 判断detailid 和 productid 是否为空,不为空才执行 保存/删除 操作
                if (DAL.Common.Utility.IsGUID(rows.Cells[0].Value.ToString()) && DAL.Common.Utility.IsGUID(rows.Cells[8].Value.ToString()))
                {
                    System.Guid          detailId  = Purchasing.PurchasingUtils.Convert.ToGuid(rows.Cells[0].Value.ToString());
                    PurchaseOrderDetails objDetail = PurchaseOrderDetails.Load(detailId);
                    DAL.Workplace        workplace = DAL.Workplace.Load(header.WorkplaceId);
                    if (objDetail == null)
                    {
                        objDetail = new PurchaseOrderDetails();
                        objDetail.OrderHeaderId = header.OrderHeaderId;
                        this.orderHeaderId      = header.OrderHeaderId;
                        objDetail.LineNumber    = Purchasing.PurchasingUtils.Convert.ToInt32(rows.Cells[1].Value.ToString().Length == 0 ? "1" : rows.Cells[1].Value.ToString());
                    }

                    objDetail.ProductId = Purchasing.PurchasingUtils.Convert.ToGuid(rows.Cells[8].Value.ToString().Trim());
                    for (int i = 9; i <= 18; i++)
                    {
                        if (workplace.WorkplaceCode == this.dgvDetailsList.Columns[i].HeaderText && rows.Cells[i].Value.ToString() != "0")
                        {
                            objDetail.OrderedQty = Purchasing.PurchasingUtils.Convert.ToDecimal(rows.Cells[i].Value.ToString().Length == 0 ? "0" : rows.Cells[i].Value.ToString());
                            result = true;
                            break;
                        }
                        else
                        {
                            result = false;
                        }
                    }

                    objDetail.UnitCost         = Purchasing.PurchasingUtils.Convert.ToDecimal(rows.Cells[7].Value.ToString().Length == 0 ? "0" : rows.Cells[7].Value.ToString());
                    objDetail.TotalQtyReceived = objDetail.OrderedQty * objDetail.UnitCost;

                    if (result)
                    {
                        if (rows.Cells[2].Value != null && rows.Cells[2].Value.ToString().Trim().ToUpper() == "REMOVED" && detailId != System.Guid.Empty)
                        {
                            objDetail.Delete();
                        }
                        else
                        {
                            objDetail.Save();
                        }
                    }
                }
            }
        }
Пример #22
0
 public void addPoDetails(int poId, List <CustomPODetails> poDetailsList)
 {
     foreach (CustomPODetails detail in poDetailsList)
     {
         PurchaseOrderDetails poDetails = new PurchaseOrderDetails();
         poDetails.PurchaseOrderId = poId;
         poDetails.Qty             = int.Parse(detail.Quantity);
         poDetails.InventoryItemId = detail.ItemId;
         poDetails.ItemCategoryId  = int.Parse(detail.CategoryId);
         dbcontext.Add(poDetails);
         dbcontext.SaveChanges();
     }
 }
Пример #23
0
        /// <summary>
        /// The purchase order has shipped, delete the notification.
        /// </summary>
        /// <param name="purchOrder"></param>
        /// <returns></returns>
        public static bool ProcessPurchaseOrderShipped(PurchaseOrderDetails purchOrder)
        {
            try
            {
                return(DashboardNotificationDAO.Delete(purchOrder.Id));
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.Notifications.PurchaseOrder.ProcessPurchaseOrderShipped()" + e.Message);
            }

            return(false);
        }
Пример #24
0
        /// <summary>
        /// Called when a new purchase order is added to the system
        /// </summary>
        /// <param name="purchOrder"></param>
        /// <returns></returns>
        public static bool ProcessNewPurchaseOrder(PurchaseOrderDetails purchOrder)
        {
            try
            {
                Notification NewNotification = GenerateNewNotification(purchOrder.Id, String.Format("New purchase order requires PayPal payment captured.  Order placed on {0} UTC with a total of {1} spent.", purchOrder.PayPalOrderDetails.OrderPlacedDateUtc.ToString("g"), (purchOrder.PayPalOrderDetails.BaseAmount + purchOrder.PayPalOrderDetails.TaxAmount + purchOrder.PayPalOrderDetails.ShippingAmount).ToString("C")));

                return(DashboardNotificationDAO.Save(NewNotification));
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.Notifications.PurchaseOrder.ProcessNewPurchaseOrder()" + e.Message);
            }

            return(false);
        }
Пример #25
0
        public ActionResult InitCheckout(string shippingMethod)
        {
            try
            {
                List <ShoppingCartProduct> ShoppingCartList = SiteContext.ShoppingCartProductList;

                SettingGroup PayPalSettings = SettingGroupDAO.LoadSettingGroupByName(SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS);

                //create auth header obj
                AuthHeader PayPalAuthHeader = Chimera.Core.PurchaseOrders.PayPalAuthHeader.GetAuthHeaderFromSetting(PayPalSettings);

                //create authorization obj
                Authorization PayPalAuthorization = new Authorization();

                string BaseWebsiteURL = CM.AppSettings["BaseWebsiteURL"];

                PayPalAuthorization.StoreImageURL   = PayPalSettings.GetSettingVal(PayPalSettingKeys.PayPal_HDRIMG);
                PayPalAuthorization.SuccessOrderURL = BaseWebsiteURL + "Order/PayPalSuccess";
                PayPalAuthorization.CancelOrderURL  = BaseWebsiteURL + "Order/PayPalCancel";

                //create purchase order details obj
                PurchaseOrderDetails PurchaseOrder = new PurchaseOrderDetails(shippingMethod, ShoppingCartList, Helpers.ShippingMethod.GetGlobalShippingMethodDictionary(null, PayPalSettings)[shippingMethod], PayPalSettings.GetSettingVal(PayPalSettingKeys.GlobalTaxAmount));

                //call paypal API to get new order details
                OrderDetails AuthOrderDetails = CompanyCommons.Ecommerce.PayPal.Functions.Execute.Authorization(PayPalAuthHeader, PayPalAuthorization, PurchaseOrder.PayPalOrderDetails, PurchaseOrder.CreatePayPalItemDescriptions());

                if (AuthOrderDetails != null)
                {
                    //store purchase order object into session
                    PurchaseOrder.PayPalOrderDetails = AuthOrderDetails;

                    //add updated info to session
                    SiteContext.PayPalPurchaseOrder = PurchaseOrder;

                    //redirect to paypal
                    return(Redirect(CompanyCommons.Ecommerce.PayPal.Functions.Execute.GetAuthorizationRedirectURL(PayPalSettings.GetSettingVal(PayPalSettingKeys.PayPal_REDIRECT), AuthOrderDetails)));
                }

                //if we got this far the call the paypal's API failed
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Controllers.OrderController.InitCheckout() " + e.Message);
            }

            //TODO: return 404 page instead?
            return(RedirectToAction("Index", "Home"));
        }
Пример #26
0
    public void CompleteOrder()
    {
        this.Status = "Completed";

        //need to get all products in the purchaseorderdetails and add them to inventory
        foreach (PurchaseOrderDetails item in PurchaseOrderDetails.GetAllAt(this.PurchaseOrders_Id))
        {
            Inventory product = Inventory.GetWithName(item.Product);

            int newStockValue = product.On_Hand + item.Quantity;

            product.ModifyItemStock(newStockValue);
            product.UpdateOnOrderQuantity(product.On_Order - item.Quantity);
        }

        this.Save();
    }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            // public PurchaseOrder(DateTime Order_Date, string Created_By, DateTime Created_Date, double Shipping_Fee, double Tax, DateTime Payment_Date, double Payment_Amount, double Order_Subtotal, double Order_Total, DateTime Date_Received, string Status)
            PurchaseOrder order = new PurchaseOrder(DateTime.Parse("2017-05-01"), k.firstName, DateTime.Parse("2017-05-01"), 20.00, .09, DateTime.Parse("2017-05-01"), totalForOrder, totalForOrder, totalForOrder, DateTime.Parse("2017-05-01"), "new");

            order.Save();
            foreach (MyItem c in list1)
            {
                PurchaseOrderDetails item = new PurchaseOrderDetails(order.PurchaseOrders_Id, c.Product, c.Quanitity, c.Price, (c.Price * c.Quanitity));
                item.Save();

                if (Inventory.GetWithName(item.Product) != null)
                {
                    Inventory invItem = Inventory.GetWithName(item.Product);
                    invItem.UpdateOnOrderQuantity(invItem.On_Order + item.Quantity);
                }
            }
        }
Пример #28
0
        public ActionResult ShipOrder(string id, string trackingNumber)
        {
            try
            {
                PurchaseOrderDetails PurchaseOrderDetail = PurchaseOrderDetailsDAO.LoadByBsonId(id);

                PurchaseOrderDetail.PayPalOrderDetails.ShippingTrackingNumber = trackingNumber;
                PurchaseOrderDetail.PayPalOrderDetails.OrderShippedDateUtc    = DateTime.UtcNow;

                if (PurchaseOrderDetailsDAO.Save(PurchaseOrderDetail))
                {
                    Chimera.Core.Notifications.PurchaseOrder.ProcessPurchaseOrderShipped(PurchaseOrderDetail);

                    try
                    {
                        List <SettingGroup> SettingGroupList = SettingGroupDAO.LoadByMultipleGroupNames(new List <string> {
                            SettingGroupKeys.TEMPLATE_CUSTOM_SETTINGS, SettingGroupKeys.EMAIL_SETTINGS
                        });

                        SettingGroup EmailSettings = SettingGroupList.Where(e => e.GroupKey.Equals(SettingGroupKeys.EMAIL_SETTINGS)).FirstOrDefault();

                        SettingGroup TemplateSettings = SettingGroupList.Where(e => e.GroupKey.Equals(SettingGroupKeys.TEMPLATE_CUSTOM_SETTINGS)).FirstOrDefault();

                        Chimera.Emails.Ecommerce.SendOrderShippedEmail(PurchaseOrderDetail, EmailSettings.GetSettingVal(EmailSettingKeys.CustomerOrderShippedEmail), EmailSettings.GetSettingVal(EmailSettingKeys.SenderEmailAddress), TemplateSettings.GetSettingVal("WebsiteTitle"));
                    }
                    catch (Exception e)
                    {
                        CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PurchaseOrdersController.ShipOrder.SendEmail()" + e.Message);
                    }

                    AddWebUserMessageToSession(Request, String.Format("Tracking # added and user notified order shipped!"), SUCCESS_MESSAGE_TYPE);
                }
                else
                {
                    AddWebUserMessageToSession(Request, String.Format("Unable to add tracking # and email user of shipped order."), FAILED_MESSAGE_TYPE);
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PurchaseOrdersController.ShipOrder()" + e.Message);
            }

            return(RedirectToAction("Search", "PurchaseOrders"));
        }
        /*
         * public DataTable SelectAll(PurchaseOrderDetails objPurchaseOrderDetails)
         * {
         *  DataSet ds = new DataSet();
         *  SqlDataAdapter da;
         *  try
         *  {
         *      SqlCommand cmd = new SqlCommand();
         *      cmd.CommandText = "PurchaseOrderDetails_SelectAll";
         *      cmd.CommandType = CommandType.StoredProcedure;
         *      cmd.Connection = ConnectionString;
         *
         *      ConnectionString.Open();
         *      da = new SqlDataAdapter(cmd);
         *      da.Fill(ds);
         *  }
         *  catch (Exception ex)
         *  {
         *      ////ErrHandler.writeError(ex.Message, ex.StackTrace);
         *      return null;
         *  }
         *  finally
         *  {
         *      ConnectionString.Close();
         *  }
         *  return ds.Tables[0];
         * }
         * public PurchaseOrderDetails SelectById(Int64 id)
         * {
         *  SqlDataAdapter da;
         *  DataSet ds = new DataSet();
         *  PurchaseOrderDetails objPurchaseOrderDetails = new PurchaseOrderDetails();
         *  try
         *  {
         *      SqlCommand cmd = new SqlCommand();
         *      cmd.CommandText = "PurchaseOrderDetails_SelectById";
         *      cmd.CommandType = CommandType.StoredProcedure;
         *      cmd.Connection = ConnectionString;
         *      cmd.Parameters.AddWithValue("@PurchaseOrderId", id);
         *      ConnectionString.Open();
         *      da = new SqlDataAdapter(cmd);
         *      da.Fill(ds);
         *
         *      if (ds != null)
         *      {
         *          if (ds.Tables.Count > 0)
         *          {
         *              if (ds.Tables[0] != null)
         *              {
         *                  if (ds.Tables[0].Rows.Count > 0)
         *                  {
         *
         *                      //PurchaseOrderId, VendorId, isdeleted, OrderDate
         *                      objPurchaseOrderDetails.PurchaseOrderDetailsId = Convert.ToInt64(ds.Tables[0].Rows[0]["PurchaseOrderDetailsId"]);
         *
         *                      objPurchaseOrderDetails.PurchaseOrderId = Convert.ToInt64(ds.Tables[0].Rows[0]["PurchaseOrderId"]);
         *                      objPurchaseOrderDetails.ProdId = Convert.ToInt64(ds.Tables[0].Rows[0]["ProdId"]);
         *                      objPurchaseOrderDetails.CategoryId = Convert.ToInt64(ds.Tables[0].Rows[0]["CategoryId"]);
         *                      objPurchaseOrderDetails.isdeleted = string.IsNullOrEmpty(ds.Tables[0].Rows[0]["isdeleted"].ToString()) ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["isdeleted"]);
         *                      objPurchaseOrderDetails.Quantity1 = Convert.ToInt64(ds.Tables[0].Rows[0]["Quantity1"]);
         *                      objPurchaseOrderDetails.Quantity = Convert.ToInt64(ds.Tables[0].Rows[0]["Quantity"]);
         *
         *
         *
         *
         *
         *                  }
         *              }
         *          }
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      ////ErrHandler.writeError(ex.Message, ex.StackTrace);
         *      return null;
         *  }
         *  finally
         *  {
         *      ConnectionString.Close();
         *  }
         *  return objPurchaseOrderDetails;
         * }
         */
        #endregion


        public Int64 Insert(PurchaseOrderDetails objPurchaseOrderDetails)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "PurchaseOrderDetails_Insert";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@PurchaseOrderDetailsId";
                param.Value         = objPurchaseOrderDetails.PurchaseOrderDetailsId;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);

                //PurchaseOrderId, ProdId, CategoryId, Quantity, isdeleted, Quantity1

                cmd.Parameters.AddWithValue("@PurchaseOrderId", objPurchaseOrderDetails.PurchaseOrderId);
                cmd.Parameters.AddWithValue("@ProdId", objPurchaseOrderDetails.ProdId);
                cmd.Parameters.AddWithValue("@CategoryId", objPurchaseOrderDetails.CategoryId);
                cmd.Parameters.AddWithValue("@Quantity", objPurchaseOrderDetails.Quantity);
                //cmd.Parameters.AddWithValue("@isdeleted", objPurchaseOrderDetails.isdeleted);
                cmd.Parameters.AddWithValue("@Quantity1", objPurchaseOrderDetails.Quantity1);



                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                //ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
Пример #30
0
        /// <summary>
        /// User redirected back here from paypal after successfully filling out all the necessary form data from paypal
        /// </summary>
        /// <returns></returns>
        public ActionResult PayPalSuccess()
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(SiteContext.PayPalPurchaseOrder.PayPalOrderDetails.PaypalInfo.Token))
                {
                    SiteContext.RecordPageView("Ecommerce_PayPalSuccess");

                    List <SettingGroup> SettingGroupList = SettingGroupDAO.LoadByMultipleGroupNames(new List <string> {
                        SettingGroupKeys.ECOMMERCE_SETTINGS, SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS
                    });

                    SettingGroup PayPalSettings = SettingGroupList.Where(e => e.GroupKey.Equals(SettingGroupKeys.PAYPAL_PURCHASE_SETTINGS)).FirstOrDefault();

                    //create auth header obj
                    AuthHeader PayPalAuthHeader = Chimera.Core.PurchaseOrders.PayPalAuthHeader.GetAuthHeaderFromSetting(PayPalSettings);

                    PurchaseOrderDetails PayPalPurchaseOrder = SiteContext.PayPalPurchaseOrder;

                    OrderDetails CheckoutOrderDetails = CompanyCommons.Ecommerce.PayPal.Functions.Execute.ExpressCheckout(PayPalAuthHeader, PayPalPurchaseOrder.PayPalOrderDetails);

                    if (CheckoutOrderDetails != null)
                    {
                        PayPalPurchaseOrder.PayPalOrderDetails = CheckoutOrderDetails;

                        SiteContext.PayPalPurchaseOrder = PayPalPurchaseOrder;

                        SettingGroup EcommerceSettings = SettingGroupList.Where(e => e.GroupKey.Equals(SettingGroupKeys.ECOMMERCE_SETTINGS)).FirstOrDefault();

                        ViewBag.PayPalSuccessModel = new PayPalSuccessModel(EcommerceSettings.GetSettingVal(ECommerceSettingKeys.FinalizeCheckoutPage), PayPalPurchaseOrder);

                        return(View("PayPalSuccess", String.Format("~/Templates/{0}/Views/Shared/Template.Master", Models.ChimeraTemplate.TemplateName)));
                    }
                }
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Controllers.OrderController.PayPalSuccess() " + e.Message);
            }

            //TODO: return 404 page instead?
            return(RedirectToAction("Index", "Home"));
        }