protected void uiGridViewPayments_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditPayment")
            {
                IStock.BLL.Payments objData = new IStock.BLL.Payments();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxCode.Text = objData.PaymentNo.ToString();
                uiTextBoxDate.Text = objData.PaymentDate.ToString("dd/MM/yyy");
                uiDropDownListClients.SelectedValue = objData.ClientID.ToString();
                if (!objData.IsColumnNull("PaymentTypeID"))
                    uiRadioButtonListPaymentType.SelectedValue = objData.PaymentTypeID.ToString();
                else
                    uiRadioButtonListPaymentType.SelectedValue = "1";

                uiDropDownListEmployee.SelectedValue = objData.EmployeeID.ToString();
                uiTextBoxAmount.Text = objData.Amount.ToString();

                uiPanelAllPayments.Visible = false;
                uiPanelEditPayment.Visible = true;

                CurrentPayment = objData;

                EnableDisableControls();
            }
            else if (e.CommandName == "DeletePayment")
            {
                try
                {
                    IStock.BLL.Payments objData = new IStock.BLL.Payments();
                    objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                    IStock.BLL.Clients client = new IStock.BLL.Clients();
                    client.LoadByPrimaryKey(objData.ClientID);
                    client.StartCredit += objData.Amount;
                    client.Save();

                    objData.MarkAsDeleted();
                    objData.Save();
                    BindPayments();
                }
                catch (Exception ex)
                {
                    uipanelError.Visible = true;
                }
            }
        }
Exemplo n.º 2
0
        protected void uiDropDownListItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            IStock.BLL.Clients client = new IStock.BLL.Clients();
            client.LoadByPrimaryKey(CurrentReturn.ClientID);

            IStock.BLL.ItemPrices price = new IStock.BLL.ItemPrices();
            price.LoadByPrimaryKey(client.ClientTypeID, Convert.ToInt32(uiDropDownListItems.SelectedValue));

            if (price.RowCount > 0)
            {
                uiTextBoxPrice.Text = price.Price.ToString();
            }
            else
            {
                uiTextBoxPrice.Text = "";
            }
        }
Exemplo n.º 3
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");
            }
        }
Exemplo n.º 4
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();
            }
        }
Exemplo n.º 5
0
        private void loadDDLs()
        {
            IStock.BLL.Clients Clients = new IStock.BLL.Clients();
            Clients.LoadAll();
            Clients.Sort = "Name";
            uiDropDownListClients.DataSource = Clients.DefaultView;
            uiDropDownListClients.DataTextField = "Name";
            uiDropDownListClients.DataValueField = "ClientID";
            uiDropDownListClients.DataBind();
            uiDropDownListClients.Items.Insert(0, new ListItem("إختر العميل",""));

            IStock.BLL.Employees employees = new IStock.BLL.Employees();
            employees.LoadAll();
            employees.Sort = "Name";
            uiDropDownListEmployee.DataSource = employees.DefaultView;
            uiDropDownListEmployee.DataTextField = "Name";
            uiDropDownListEmployee.DataValueField = "EmployeeID";
            uiDropDownListEmployee.DataBind();
            uiDropDownListEmployee.Items.Insert(0, new ListItem("إختر الموظف",""));

               /* IStock.BLL.Items items = new IStock.BLL.Items();
            items.LoadAll();
            items.Sort = "Name";
            uiDropDownListItems.DataSource = items.DefaultView;
            uiDropDownListItems.DataTextField = "Name";
            uiDropDownListItems.DataValueField = "ItemID";
            uiDropDownListItems.DataBind();
            uiDropDownListItems.Items.Insert(0, new ListItem("إختر الصنف",""));*/
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        protected void uiGridViewItems_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteDetail")
            {
                IStock.BLL.DeliveryOrderDetails objData = new IStock.BLL.DeliveryOrderDetails();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                decimal price = 0;
                if (!CurrentDeliveryOrder.IsColumnNull("Discount") && CurrentDeliveryOrder.Discount != 0)
                {
                    price = objData.ItemPrice * objData.Quantity * (CurrentDeliveryOrder.Discount / 100);
                }
                else
                {
                    price = objData.ItemPrice * objData.Quantity;
                }

                /* restore items to stock */
                IStock.BLL.Items item = new IStock.BLL.Items();
                item.LoadByPrimaryKey(objData.ItemID);
                item.Quantity += objData.Quantity;
                item.Save();
                /* restore items to stock */

                IStock.BLL.Clients client = new IStock.BLL.Clients();
                client.LoadByPrimaryKey(CurrentDeliveryOrder.ClientID);
                client.StartCredit -= price;
                client.Save();

                objData.MarkAsDeleted();
                objData.Save();
                BindItems();
            }
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        protected void uiGridViewOrders_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditOrder")
            {
                IStock.BLL.DeliveryOrder objData = new IStock.BLL.DeliveryOrder();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxCode.Text = objData.DeliveryOrderNo;
                uiTextBoxDate.Text = objData.DeliveryOrderDate.ToString("dd/MM/yyy");
                uiDropDownListClients.SelectedValue = objData.ClientID.ToString();
                uiDropDownListEmployee.SelectedValue = objData.EmployeeID.ToString();
                if(!objData.IsColumnNull("Discount"))
                    uiTextBoxDiscount.Text = objData.Discount.ToString();
                uiPanelAllOrders.Visible = false;
                uiPanelEditDeliveryOrder.Visible = true;
                uiPanelItems.Visible = true;
                CurrentDeliveryOrder = objData;
                //EnableDisableActions();
                BindItems();
            }
            else if (e.CommandName == "DeleteOrder")
            {
                try
                {
                    IStock.BLL.DeliveryOrder objData = new IStock.BLL.DeliveryOrder();
                    objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                    IStock.BLL.DeliveryOrderDetails details = new IStock.BLL.DeliveryOrderDetails();
                    details.GetDeliveryOrderDetails(objData.DeliveryOrderID);

                    decimal total = objData.GetDeliveryOrderTotals(objData.DeliveryOrderID);

                    /* restore items to stock */
                    for (int i = 0; i < details.RowCount; i++)
                    {
                        IStock.BLL.Items item = new IStock.BLL.Items();
                        item.LoadByPrimaryKey(details.ItemID);
                        item.Quantity += details.Quantity;
                        details.MoveNext();
                        item.Save();
                    }
                    /* restore items to stock */

                    details.MarkAsDeleted();
                    details.Save();

                    /* update client credit */
                    IStock.BLL.Clients client = new IStock.BLL.Clients();
                    client.LoadByPrimaryKey(objData.ClientID);
                    client.StartCredit -= total;
                    client.Save();
                    /* update client credit */

                    IStock.BLL.ClientReturns cr = new IStock.BLL.ClientReturns ();
                    cr.GetClientReturnByDeliveryOrderID(objData.DeliveryOrderID);
                    if (cr.RowCount > 0)
                    {
                        cr.SetColumnNull("DeliveryOrderID");
                        cr.Save();
                    }

                    objData.MarkAsDeleted();
                    objData.Save();

                    CurrentDeliveryOrder = null;
                    BindOrders();
                }
                catch (Exception ex)
                {
                    uipanelError.Visible = true;
                }
            }
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
0
 private void LoadClients()
 {
     IStock.BLL.Clients clients = new IStock.BLL.Clients();
     clients.GetAllClientsByClientTypeID(Convert.ToInt32(uiDropDownListClientTypes.SelectedValue));
     uiDropDownListClients.DataSource = clients.DefaultView;
     uiDropDownListClients.DataTextField = "Name";
     uiDropDownListClients.DataValueField = "ClientID";
     uiDropDownListClients.DataBind();
     uiDropDownListClients.Items.Insert(0, new ListItem("إختر عميل", "0"));
 }
Exemplo n.º 12
0
        protected void uiLinkButtonOrdersForClient_Click(object sender, EventArgs e)
        {
            uiReportViewerMain.Reset();
            uiReportViewerMain.LocalReport.ReportPath = BaseReportPath + "Report_GetOrdersHistoryByClientID.rdlc";
            IStock.BLL.Clients client = new IStock.BLL.Clients();

            DateTime? From = null, To = null;
            if (!string.IsNullOrEmpty(uiTextBoxFrom.Text))
                From = DateTime.ParseExact(uiTextBoxFrom.Text, "dd/MM/yyyy", null);
            if (!string.IsNullOrEmpty(uiTextBoxTo.Text))
                To = DateTime.ParseExact(uiTextBoxTo.Text, "dd/MM/yyyy", null);

            int clientID = 0;
            if (!string.IsNullOrEmpty(uiDropDownListClients.SelectedValue))
                clientID = Convert.ToInt32(uiDropDownListClients.SelectedValue);

            if (!string.IsNullOrEmpty(uiHiddenFieldCurrentItem.Value))
                client.Report_GetOrdersHistoryByClientID(clientID, From, To, Convert.ToInt32(uiHiddenFieldCurrentItem.Value));
            else
                client.Report_GetOrdersHistoryByClientID(clientID, From, To, 0);

            uiReportViewerMain.LocalReport.DataSources.Clear();
            uiReportViewerMain.LocalReport.DataSources.Add(new ReportDataSource("Report_GetOrdersHistoryByClientIDDataSet", client.DefaultView));
            uiReportViewerMain.LocalReport.SetParameters(new ReportParameter("From", uiTextBoxFrom.Text));
            uiReportViewerMain.LocalReport.SetParameters(new ReportParameter("To", uiTextBoxTo.Text));
            uiReportViewerMain.LocalReport.Refresh();
        }
Exemplo n.º 13
0
 protected void uiLinkButtonAdd_Click(object sender, EventArgs e)
 {
     ClearFields();
     CurrentClient = null;
     uiPanelEditClients.Visible = true;
     uiPanelAllClients.Visible = false;
 }
Exemplo n.º 14
0
 private void BindClients()
 {
     IStock.BLL.Clients clients = new IStock.BLL.Clients();
     clients.GetAllClients();
     uiGridViewClients.DataSource = clients.DefaultView;
     uiGridViewClients.DataBind();
 }
Exemplo n.º 15
0
        protected void uiLinkButtonOK_Click(object sender, EventArgs e)
        {
            IStock.BLL.Clients clients = new IStock.BLL.Clients();
            if (CurrentClient == null)
                clients.AddNew();
            else
                clients = CurrentClient;

            clients.Name = uiTextBoxName.Text;
            clients.Description = uiTextBoxDesc.Text;
            clients.Address = uiTextBoxAddress.Text;
            clients.Telephone = uiTextBoxTele.Text;
            clients.CityID = Convert.ToInt32(uiDropDownListCities.SelectedValue);
            clients.ClientTypeID = Convert.ToInt32(uiDropDownListClientTypes.SelectedValue);
            if(!string.IsNullOrEmpty(uiTextBoxCredit.Text))
                clients.StartCredit = decimal.Parse(uiTextBoxCredit.Text);
            clients.Save();
            ClearFields();
            CurrentClient = null;
            uiPanelEditClients.Visible = false;
            uiPanelAllClients.Visible = true;
            BindClients();
        }