Ejemplo n.º 1
0
        protected void uiGridViewClients_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditClient")
            {
                IStock.BLL.Clients objData = new IStock.BLL.Clients();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxName.Text = objData.Name;
                uiTextBoxDesc.Text = objData.Description;
                uiTextBoxAddress.Text = objData.Address;
                uiTextBoxTele.Text = objData.Telephone;
                uiDropDownListCities.SelectedValue = objData.CityID.ToString();
                uiDropDownListClientTypes.SelectedValue = objData.ClientTypeID.ToString();
                if(!objData.IsColumnNull("StartCredit"))
                    uiTextBoxCredit.Text = objData.StartCredit.ToString();

                uiPanelAllClients.Visible = false;
                uiPanelEditClients.Visible = true;
                CurrentClient = objData;

                BindClients();
            }
            else if (e.CommandName == "DeleteClient")
            {
                try
                {
                    IStock.BLL.Clients objData = new IStock.BLL.Clients();
                    objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                    objData.MarkAsDeleted();
                    objData.Save();
                    CurrentClient = null;
                    BindClients();
                }
                catch (Exception ex)
                {

                }
            }

            else if (e.CommandName == "GetClientCredit")
            {
                Session["Report_ClientIDForCredit"] = e.CommandArgument.ToString();
                Session["CurrentReport"] = "Report_GetClientCredit";
                Response.Redirect("Reports.aspx");
            }
        }
Ejemplo n.º 2
0
        protected void uiLinkButtonAddItem_Click(object sender, EventArgs e)
        {
            IStock.BLL.ClientReturnDetails detail = new IStock.BLL.ClientReturnDetails();
            detail.AddNew();
            detail.ClientReturnID = CurrentReturn.ClientReturnID;
            //if (uiDropDownListItems.SelectedIndex != -1)
            if (!string.IsNullOrEmpty(uiHiddenFieldCurrentItem.Value))
            {
                //detail.ItemID = Convert.ToInt32(uiDropDownListItems.SelectedValue);
                detail.ItemID = Convert.ToInt32(uiHiddenFieldCurrentItem.Value);
            }
            else
            {
                uiPanelErrorItems.Visible = true;
                return;
            }
            try
            {
                detail.Quantity = Convert.ToInt32(uiTextBoxQty.Text);
            }
            catch (Exception ex)
            {
                return;
            }
            try
            {
                detail.Valid = Convert.ToInt32(uiTextBoxValid.Text);
            }
            catch (Exception ex)
            {
                return;
            }
            try
            {
                detail.ItemPrice = decimal.Parse(uiTextBoxPrice.Text);
            }
            catch (Exception ex)
            {
                return;
            }
            detail.Save();
            uiPanelErrorItems.Visible = false;

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

            IStock.BLL.Clients client = new IStock.BLL.Clients();
            client.LoadByPrimaryKey(CurrentReturn.ClientID);
            if (!client.IsColumnNull("StartCredit"))
                client.StartCredit -= price;
            else
                client.StartCredit = -price;
            client.Save();

            IStock.BLL.Items item = new IStock.BLL.Items();
            item.LoadByPrimaryKey(detail.ItemID);
            item.Quantity += detail.Valid;
            item.Save();

            BindItems();
        }
Ejemplo n.º 3
0
        protected void uiLinkButtonAddItem_Click(object sender, EventArgs e)
        {
            /* get items from stock */
            IStock.BLL.Items item = new IStock.BLL.Items();
            item.LoadByPrimaryKey(Convert.ToInt32(uiHiddenFieldCurrentItem.Value));
            if (!item.IsColumnNull("Quantity"))
            {
                if (item.Quantity == 0 || Convert.ToInt32(uiTextBoxQty.Text) > item.Quantity)
                {
                    ErrorDiv.Visible = true;
                    uiLabelError.Text = GetLocalResourceObject("ItemQtyError").ToString();
                    return;
                }
                item.Quantity -= Convert.ToInt32(uiTextBoxQty.Text);

            }
            else
            {
                ErrorDiv.Visible = true;
                uiLabelError.Text = GetLocalResourceObject("ItemQtyError").ToString();
                return;
            }
            item.Save();
            /* get items from stock */

            IStock.BLL.DeliveryOrderDetails detail = new IStock.BLL.DeliveryOrderDetails();
            detail.AddNew();
            detail.DeliveryOrderID = CurrentDeliveryOrder.DeliveryOrderID;
            detail.ItemID = Convert.ToInt32(uiHiddenFieldCurrentItem.Value);
            //detail.ItemID = Convert.ToInt32(uiDropDownListItems.SelectedValue);
            detail.Quantity = Convert.ToInt32(uiTextBoxQty.Text);
            detail.ItemPrice = decimal.Parse(uiTextBoxPrice.Text);
            detail.Save();

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

            IStock.BLL.Clients client = new IStock.BLL.Clients();
            client.LoadByPrimaryKey(CurrentDeliveryOrder.ClientID);
            if (!client.IsColumnNull("StartCredit"))
                client.StartCredit += price;
            else
                client.StartCredit = price;
            client.Save();
            ErrorDiv.Visible = false;
            uiTextBoxItems.Text = "";
            uiTextBoxPrice.Text = "";
            uiTextBoxQty.Text = "";
            BindItems();
        }
Ejemplo n.º 4
0
        protected void uiLinkButtonConfirm_Click(object sender, EventArgs e)
        {
            IStock.BLL.Clients client = new IStock.BLL.Clients();
            client.LoadByPrimaryKey(CurrentPayment.ClientID);
            if (!client.IsColumnNull("StartCredit"))
                client.StartCredit -= CurrentPayment.Amount;
            else
                client.StartCredit = 0 - CurrentPayment.Amount;

            client.Save();
            CurrentPayment.Confirmed = true;
            CurrentPayment.Save();
            EnableDisableControls();
        }