예제 #1
0
        protected void uiGridViewItems_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteDetail")
            {
                IStock.BLL.ClientReturnDetails objData = new IStock.BLL.ClientReturnDetails();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                decimal price = 0;
                if (!objData.IsColumnNull("Discount") && objData.Discount != 0)
                {
                    price = objData.ItemPrice * objData.Quantity * (objData.Discount / 100);
                }
                else
                {
                    price = objData.ItemPrice * objData.Quantity;
                }

                IStock.BLL.Clients client = new IStock.BLL.Clients();
                IStock.BLL.ClientReturns returns = new IStock.BLL.ClientReturns ();
                returns.LoadByPrimaryKey(objData.ClientReturnID);
                client.LoadByPrimaryKey(returns.ClientID);
                client.StartCredit += price;
                client.Save();

                IStock.BLL.Items item = new IStock.BLL.Items();
                item.LoadByPrimaryKey(objData.ItemID);
                if(!objData.IsColumnNull("Valid"))
                    item.Quantity -= objData.Valid;
                item.Save();

                objData.MarkAsDeleted();
                objData.Save();
                BindItems();
            }
        }
예제 #2
0
        protected void uiGridViewReturns_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditReturn")
            {
                IStock.BLL.ClientReturns objData = new IStock.BLL.ClientReturns();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxCode.Text = objData.ReturnNo;
                uiTextBoxDate.Text = objData.ReturnDate.ToString("dd/MM/yyy");
                uiDropDownListClients.SelectedValue = objData.ClientID.ToString();
                uiDropDownListEmployee.SelectedValue = objData.EmployeeID.ToString();
                if (!objData.IsColumnNull("Discount"))
                    uiTextBoxDiscount.Text = objData.Discount.ToString();
                uiPanelAllReturns.Visible = false;
                uiPanelEditReturn.Visible = true;
                uiPanelItems.Visible = true;
                CurrentReturn = objData;
                BindItems();
            }
            else if (e.CommandName == "DeleteReturn")
            {
                try
                {
                    IStock.BLL.ClientReturns objData = new IStock.BLL.ClientReturns();
                    objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                    IStock.BLL.ClientReturnDetails details = new IStock.BLL.ClientReturnDetails();
                    details.GetClientReturnDetails(objData.ClientReturnID);

                    details.MarkAsDeleted();
                    details.Save();
                    /*
                    IStock.BLL.Clients client = new IStock.BLL.Clients();
                    client.LoadByPrimaryKey(objData.ClientID);
                    client.StartCredit -= total;
                    client.Save();
                    */
                    objData.MarkAsDeleted();
                    objData.Save();
                    CurrentReturn = null;
                    BindReturns();
                }
                catch (Exception ex)
                {
                    uipanelError.Visible = true;
                }
            }
        }