Esempio n. 1
0
        protected void tblClaimUnitList_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string nomNum = ((DataRowView)e.Row.DataItem)["nomenclature_num"].ToString();

                if (!String.IsNullOrEmpty(nomNum))
                {
                    DataTable dt = Db.Db.Zipcl.GetNomenclatureDataByNumber(nomNum);//Берем данные по позиции из Эталон

                    if (dt.Rows.Count > 0)
                    {
                        (e.Row.FindControl("lblEtCount") as Label).Text = dt.Rows[0]["count"].ToString();

                        string priceStr = dt.Rows[0]["price"].ToString();

                        (e.Row.FindControl("lblEtPrice") as Label).Text = priceStr;

                        Label lblPriceIn = (e.Row.FindControl("lblPriceIn") as Label);

                        if (!priceStr.Equals("-") && lblPriceIn != null && String.IsNullOrEmpty(lblPriceIn.Text))
                        {
                            decimal priceIn;
                            decimal.TryParse(priceStr.Replace('.', ','), out priceIn);

                            int priceInInt = Convert.ToInt32((Math.Ceiling(priceIn / 10) * 10));

                            lblPriceIn.Text = priceInInt.ToString();

                            int count = Convert.ToInt32((e.Row.FindControl("lblCount") as Label).Text);

                            (e.Row.FindControl("lblPriceInSum") as Label).Text = (priceInInt * count).ToString();

                            int idClaimUnit = Convert.ToInt32((e.Row.FindControl("lblIdClaimUnit") as Label).Text);

                            ClaimUnit cu = new ClaimUnit(idClaimUnit);
                            cu.PriceIn = priceInInt;
                            cu.Save();
                        }
                    }
                }

                #region PriceRequest

                //Если есть хотя бы одна позиция без цены и срока, то можно передать запрос цен в снабжение
                bool haveUnit2SendPriceRequest = false;

                var dataItem = (DataRowView)e.Row.DataItem;

                if (dataItem != null)
                {
                    string priceIn = dataItem["price_in"].ToString();
                    string deliveryTime = dataItem["delivery_time"].ToString();

                    if (String.IsNullOrEmpty(priceIn) && String.IsNullOrEmpty(deliveryTime))
                    {
                        haveUnit2SendPriceRequest = true;
                    }
                }

                if (!btnRequestPrice.Visible && e.Row.RowIndex > 0)//В нулевой строке содежится пустые данные всегда
                {
                    btnRequestPrice.Visible = btnRequestPriceDisplay && haveUnit2SendPriceRequest;
                }

                #endregion
            }
        }
Esempio n. 2
0
        protected void txtClaimUnitComment_OnTextChanged(object sender, EventArgs e)
        {
            TextBox txt = (TextBox)sender;

            string catNum = txt.Attributes["cat_num"];
            string descr = MainHelper.TxtGetText(ref txt);

            ClaimUnit cu = new ClaimUnit() { CatalogNum = catNum, Descr = descr, IdCreator = User.Id };
            try
            {
                cu.SaveInfo();
            }
            catch (Exception ex)
            {
                ServerMessageDisplay(new[] { phServerMessage }, ex.Message, true);
            }
        }
Esempio n. 3
0
        protected void btnAddNew_OnCLick(object sender, EventArgs e)
        {
            GridViewRow footer = tblClaimUnitList.FooterRow;

            ClaimUnit claimUnit = new ClaimUnit();
            claimUnit.IdClaim = Id;

            TextBox txtCatalogNum = (TextBox)footer.FindControl("txtCatalogNum");
            claimUnit.CatalogNum = MainHelper.TxtGetText(ref txtCatalogNum);

            TextBox txtName = (TextBox)footer.FindControl("txtName");
            claimUnit.Name = MainHelper.TxtGetText(ref txtName);

            TextBox txtCount = (TextBox)footer.FindControl("txtCount");
            claimUnit.Count = MainHelper.TxtGetTextInt32(ref txtCount);

            //TextBox txtDeliveryTime = (TextBox)footer.FindControl("txtDeliveryTime");
            //claimUnit.DeliveryTime = MainHelper.TxtGetText(ref txtDeliveryTime);

            //TextBox txtPriceIn = (TextBox)footer.FindControl("txtPriceIn");
            //claimUnit.PriceIn = MainHelper.TxtGetTextInt32(ref txtPriceIn);

            //TextBox txtPriceOut = (TextBox)footer.FindControl("txtPriceOut");
            //claimUnit.PriceOut = MainHelper.TxtGetTextInt32(ref txtPriceOut);

            claimUnit.IdCreator = User.Id;

            claimUnit.Save();

            //RedirectWithParams();
            tblClaimUnitList.DataBind();

            lLastClaim.Text = String.Empty;
            (tblClaimUnitList.FooterRow.FindControl("txtCatalogNum") as TextBox).Focus();
        }
Esempio n. 4
0
        private ClaimUnit GetClaimUnitData(int rowIndex)
        {
            ClaimUnit cu = new ClaimUnit();

            GridViewRow row = tblClaimUnitList.Rows[rowIndex];

            Label lblIdClaimUnit = (row.FindControl("lblIdClaimUnit") as Label);
            cu.Id = MainHelper.LblGetValueInt32(ref lblIdClaimUnit);

            cu.IdClaim = Id;

            TextBox txtCatalogNum = (row.FindControl("txtCatalogNum") as TextBox);
            cu.CatalogNum = MainHelper.TxtGetText(ref txtCatalogNum);

            TextBox txtName = (row.FindControl("txtName") as TextBox);
            cu.Name = MainHelper.TxtGetText(ref txtName);

            TextBox txtNomenclatureNum = (row.FindControl("txtNomenclatureNum") as TextBox);
            cu.NomenclatureNum = MainHelper.TxtGetText(ref txtNomenclatureNum);

            CheckBoxList chklNoNomNum = row.FindControl("chklNoNomNum") as CheckBoxList;
            cu.NoNomenclatureNum = chklNoNomNum.SelectedValue == "1";

            TextBox txtDeliveryTime = (row.FindControl("txtDeliveryTime") as TextBox);
            //cu.DeliveryTime = MainHelper.TxtGetText(ref txtDeliveryTime);
            cu.DeliveryTime = txtDeliveryTime.Text;//Чтобы можно было очистить

            TextBox txtPriceIn = (row.FindControl("txtPriceIn") as TextBox);
            //cu.PriceIn = MainHelper.TxtGetTextDecimal(ref txtPriceIn);
            decimal? priceIn = MainHelper.TxtGetTextDecimal(ref txtPriceIn, true);
            cu.PriceIn = priceIn ?? -9999;//Чтобы можно было очистить

            TextBox txtPriceOut = (row.FindControl("txtPriceOut") as TextBox);
            //cu.PriceOut = MainHelper.TxtGetTextDecimal(ref txtPriceOut, true);
            decimal? priceOut = MainHelper.TxtGetTextDecimal(ref txtPriceOut, true);
            cu.PriceOut = priceOut ?? -9999;//Чтобы можно было очистить

            cu.IdCreator = User.Id;

            return cu;
        }
Esempio n. 5
0
        protected void btnAddNewOftenSelected_OnCLick(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in rtrOftenSelected.Items)
            {
                CheckBox chkOftenSelectedSet = (CheckBox)item.FindControl("chkOftenSelectedSet");

                if (chkOftenSelectedSet.Checked)
                {
                    ClaimUnit claimUnit = new ClaimUnit();
                    claimUnit.IdClaim = Id;

                    Label lblOftenSelectedCatalogNum = (Label)item.FindControl("lblOftenSelectedCatalogNum");
                    claimUnit.CatalogNum = lblOftenSelectedCatalogNum.Text;

                    Label lblOftenSelectedName = (Label)item.FindControl("lblOftenSelectedName");
                    claimUnit.Name = lblOftenSelectedName.Text;

                    TextBox txtCount = (TextBox)item.FindControl("txtOftenSelectedCount");
                    claimUnit.Count = MainHelper.TxtGetTextInt32(ref txtCount);

                    claimUnit.IdCreator = User.Id;

                    claimUnit.Save(true);
                }
            }

            foreach (RepeaterItem item in rtrOftenSelected2.Items)
            {
                CheckBox chkOftenSelectedSet = (CheckBox)item.FindControl("chkOftenSelectedSet");

                if (chkOftenSelectedSet.Checked)
                {
                    ClaimUnit claimUnit = new ClaimUnit();
                    claimUnit.IdClaim = Id;

                    Label lblOftenSelectedCatalogNum = (Label)item.FindControl("lblOftenSelectedCatalogNum");
                    claimUnit.CatalogNum = lblOftenSelectedCatalogNum.Text;

                    Label lblOftenSelectedName = (Label)item.FindControl("lblOftenSelectedName");
                    claimUnit.Name = lblOftenSelectedName.Text;

                    TextBox txtCount = (TextBox)item.FindControl("txtOftenSelectedCount");
                    claimUnit.Count = MainHelper.TxtGetTextInt32(ref txtCount);

                    claimUnit.IdCreator = User.Id;

                    claimUnit.Save(true);
                }
            }

            foreach (RepeaterItem item in rtrOftenSelected3.Items)
            {
                CheckBox chkOftenSelectedSet = (CheckBox)item.FindControl("chkOftenSelectedSet");

                if (chkOftenSelectedSet.Checked)
                {
                    ClaimUnit claimUnit = new ClaimUnit();
                    claimUnit.IdClaim = Id;

                    Label lblOftenSelectedCatalogNum = (Label)item.FindControl("lblOftenSelectedCatalogNum");
                    claimUnit.CatalogNum = lblOftenSelectedCatalogNum.Text;

                    Label lblOftenSelectedName = (Label)item.FindControl("lblOftenSelectedName");
                    claimUnit.Name = lblOftenSelectedName.Text;

                    TextBox txtCount = (TextBox)item.FindControl("txtOftenSelectedCount");
                    claimUnit.Count = MainHelper.TxtGetTextInt32(ref txtCount);

                    claimUnit.IdCreator = User.Id;

                    claimUnit.Save(true);
                }
            }

            rtrOftenSelected.DataBind();
            rtrOftenSelected2.DataBind();
            rtrOftenSelected3.DataBind();
            tblClaimUnitList.DataBind();
            (tblClaimUnitList.FooterRow.FindControl("txtCatalogNum") as TextBox).Focus();
        }
Esempio n. 6
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            int id = Convert.ToInt32((sender as LinkButton).CommandArgument);
            int rowIndex = -1;

            foreach (GridViewRow row in tblList.Rows)
            {
                int currId = Convert.ToInt32(((HiddenField)row.FindControl("hfIdClaimUnit")).Value);
                if (currId == id)
                {
                    rowIndex = row.RowIndex;
                    break;
                }
            }

            if (rowIndex >= 0)
            {
                HiddenField hfIdClaim = (HiddenField)tblList.Rows[rowIndex].FindControl("hfIdClaim");
                int idClaim = MainHelper.HfGetValueInt32(ref hfIdClaim);

                TextBox txtPriceIn = (TextBox)tblList.Rows[rowIndex].FindControl("txtPriceIn");
                decimal priceIn = MainHelper.TxtGetTextDecimal(ref txtPriceIn);

                TextBox txtDeliveryTime = (TextBox)tblList.Rows[rowIndex].FindControl("txtDeliveryTime");
                string deliveryTime = MainHelper.TxtGetText(ref txtDeliveryTime);

                TextBox txtNomenclatureNum = (TextBox)tblList.Rows[rowIndex].FindControl("txtNomenclatureNum");
                string nomenclatureNum = MainHelper.TxtGetText(ref txtNomenclatureNum);

                ClaimUnit cu = new ClaimUnit()
                {
                    Id = id,
                    IdClaim = idClaim,
                    PriceIn = priceIn,
                    DeliveryTime = deliveryTime,
                    IdCreator = User.Id,
                    Count = null,
                    NomenclatureNum = nomenclatureNum,
                    IdSupplyMan = User.Id
                };

                try
                {
                    cu.Save();
                }
                catch (Exception ex)
                {
                    ServerMessageDisplay(new[] { phServerMessage }, ex.Message, true);
                }

                Claim c = new Claim() { Id = idClaim, IdCreator = User.Id };

                try
                {
                    c.SetPriceSetState(true);
                }
                catch (Exception ex)
                {
                    ServerMessageDisplay(new[] { phServerMessage }, ex.Message, true);
                }

                tblList.DataBind();
            }

            SetRowEditState(id, false);
        }
Esempio n. 7
0
        protected void btnSendReturn_OnClick(object sender, EventArgs e)
        {
            int id = Convert.ToInt32((sender as LinkButton).CommandArgument);
            int rowIndex = -1;

            foreach (GridViewRow row in tblList.Rows)
            {
                int currId = Convert.ToInt32(((HiddenField)row.FindControl("hfIdClaimUnit")).Value);
                if (currId == id)
                {
                    rowIndex = row.RowIndex;
                    break;
                }
            }

            //((WebControl)sender).NamingContainer.ID

            if (rowIndex >= 0)
            {
                HiddenField hfIdClaim = (HiddenField)tblList.Rows[rowIndex].FindControl("hfIdClaim");
                int idClaim = MainHelper.HfGetValueInt32(ref hfIdClaim);
                var txtReturnDescr = tblList.Rows[rowIndex].FindControl("txtReturnDescr") as TextBox;
                string descr = MainHelper.TxtGetText(ref txtReturnDescr);

                ClaimUnit cu = new ClaimUnit()
                {
                    Id = id,
                    IdClaim = idClaim,
                    IdCreator = User.Id
                };

                try
                {
                    cu.SupplyReturn(descr);
                }
                catch (Exception ex)
                {
                    ServerMessageDisplay(new[] { phServerMessage }, ex.Message, true);
                }

                Claim c = new Claim() { Id = idClaim, IdCreator = User.Id };

                try
                {
                    c.SupplyReturnClaim();
                }
                catch (Exception ex)
                {
                    ServerMessageDisplay(new[] { phServerMessage }, ex.Message, true);
                }

                tblList.DataBind();
            }

            SetRowEditState(id, false);
        }