예제 #1
0
        public bool UpdateFOrder(FOrder ent)
        {
            bool      success = true;
            FOrderDAO entDAO  = new FOrderDAO();

            sc             = new SqlCommand("UpdateFOrder");
            sc.CommandType = CommandType.StoredProcedure;
            sc.Parameters.Add("@ID", ent.ID);
            sc.Parameters.Add("@IsPaid", ent.IsPaid);
            sc.Parameters.Add("@UserID", ent.UserID);
            if (ent.DateOut == null)
            {
                sc.Parameters.Add("@DateOut", DBNull.Value);
            }
            else
            {
                sc.Parameters.Add("@DateOut", ent.DateOut);
            }
            if (ent.PaymentDay == null)
            {
                sc.Parameters.Add("@PaymentDay", DBNull.Value);
            }
            else
            {
                sc.Parameters.Add("@PaymentDay", ent.PaymentDay.Value);
            }
            //addParameters(ent);
            success = entDAO.updateEntity(sc);
            return(success);
        }
예제 #2
0
        public FOrder createEntityFromReader(SqlDataReader dr)
        {
            FOrder ent = new FOrder();

            if (!dr.IsDBNull(dr.GetOrdinal("ID")))
            {
                ent.ID = Convert.ToInt32(dr["ID"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("FAbonentID")))
            {
                ent.FAbonentID = Convert.ToInt32(dr["FAbonentID"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("DateIn")))
            {
                ent.DateIn = Convert.ToDateTime(dr["DateIn"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("DateOut")))
            {
                ent.DateOut = Convert.ToDateTime(dr["DateOut"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("Coment")))
            {
                ent.Coment = dr["Coment"].ToString();
            }

            if (!dr.IsDBNull(dr.GetOrdinal("IsPaid")))
            {
                ent.IsPaid = Convert.ToBoolean(dr["IsPaid"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("ActionType")))
            {
                ent.ActionType = dr["ActionType"].ToString();
            }

            if (!dr.IsDBNull(dr.GetOrdinal("PaymentDay")))
            {
                ent.PaymentDay = Convert.ToDateTime(dr["PaymentDay"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("UserID")))
            {
                ent.UserID = Convert.ToInt32(dr["UserID"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("Prefix")))
            {
                ent.Prefix = dr["Prefix"].ToString();
            }

            return(ent);
        }
예제 #3
0
        public int Create(FOrder ent)
        {
            int       createdid = 0;
            FOrderDAO entDAO    = new FOrderDAO();

            sc             = new SqlCommand("CreateFOrder");
            sc.CommandType = CommandType.StoredProcedure;
            addParameters(ent);
            createdid = entDAO.createEntity(sc);
            return(createdid);
        }
예제 #4
0
        public override UniversalEntity createEntity()
        {
            UniversalEntity ue = new UniversalEntity();

            while (dr.Read())
            {
                FOrder ent = new FOrder();
                ent = createEntityFromReader(dr);
                ue.Add(ent);
            }
            return(ue);
        }
예제 #5
0
        void Txt_order_id_NewEntryNeeded(object sender, string pValue)
        {
            if (forder == null)
            {
                forder = new FOrder();
            }
            Parent.Controls.Add(forder);
            forder.Dock = DockStyle.Fill;
            forder.Show();
            forder.BringToFront();
            forder.Focus();

            forder.SetAction(BtnEvent.New, null);
            forder.SetFocus();
        }
예제 #6
0
        void Txt_order_NewEntryNeeded(object sender, string pValue)
        {
            if (xorder == null)
            {
                xorder = new FOrder();
                xorder.FOrder_NeedToRefresh += Order_NeedToRefresh;
            }
            this.Parent.Controls.Add(xorder);
            xorder.Dock = DockStyle.Fill;
            xorder.Show();
            xorder.BringToFront();
            xorder.Focus();

            xorder.SetAction(BtnEvent.New, null);
            xorder.SetFocus();
            //xorder.setname(pValue);
        }
예제 #7
0
        public void EditorMode()
        {
            User u = GetCurrentUser();

            u.GetPermissions();
            //проверяем наличие прав для редактировнаия
            if (u.ChekPermission("Editor"))
            {
                punAdonentEditor.Visible = true;
                gvJournal.Visible        = false;
                gvJournal2.Visible       = true;
                BindDistricts();
                UniversalEntity ue   = new UniversalEntity();
                FAbonent        fa   = new FAbonent();
                FAbonentDO      fado = new FAbonentDO();
                ue = fado.RetrieveByOrderID(_OrderID);
                if (ue.Count > 0)
                {
                    fa = (FAbonent)ue[0];
                    tbNumberJournalPhysical.Text = fa.PhysicalNumberJournal;
                    tbAddress.Text            = fa.Address;
                    tbClientSurname.Text      = fa.Surname;
                    ddlDistrict.SelectedValue = fa.DistrictID.ToString();
                    tbClientName.Text         = fa.FirstName;
                    tbClientLastName.Text     = fa.LastName;
                    tbPhone.Text     = fa.Phone;
                    cbNotPay.Checked = fa.NotPay;
                    //cbRejectVodomer.Checked = fa.RejectVodomer;
                }
                FOrder   fo    = new FOrder();
                FOrderDO fodDO = new FOrderDO();
                ue = fodDO.RetrieveFOrderById(_OrderID);
                if (ue.Count > 0)
                {
                    fo = (FOrder)ue[0];
                    cbDefectVodomer.Checked = fo.DefectVodomer;
                }
            }
            else
            {
                punAdonentEditor.Visible = false;
                gvJournal.Visible        = true;
                gvJournal2.Visible       = false;
            }
        }
예제 #8
0
        //Сохраняем всё
        protected void lbSaveAll_Click(object sender, EventArgs e)
        {
            string errorMessage = string.Empty;
            bool   ok           = true;

            foreach (GridViewRow r in gvJournal.Rows)
            {
                if (string.IsNullOrEmpty((r.FindControl("litEndValue") as Literal).Text) && cbSeld.Checked)
                {
                    errorMessage += "Необходимо заполнить конечные показания водомеров.<br/>";
                    ok            = false;
                    break;
                }
            }
            if (cbPaid.Checked && string.IsNullOrEmpty(tbPaymentDay.Text))
            {
                ok            = false;
                errorMessage += "Необходимо заполнить дату оплаты.<br/>";
            }
            if (!ok)
            {
                radWM.RadAlert(errorMessage, null, null, "Предупреждение", "");
                //SetMessege("Предупреждение", errorMessage);
            }
            else
            {
                FOrder   fo   = new FOrder();
                FOrderDO fodo = new FOrderDO();
                fo.ID         = Convert.ToInt32(hfODID.Value);
                fo.IsPaid     = cbPaid.Checked;
                fo.UserID     = GetCurrentUser().ID;
                fo.PaymentDay = Convert.ToDateTime(tbPaymentDay.Text);
                if (cbSeld.Checked)
                {
                    fo.DateOut = DateTime.Now;
                }
                bool rez = fodo.UpdateFOrder(fo);

                //(this.Parent.FindControl("gvJournal") as GridView).DataBind();
                //this.Visible = false;
                _OrderID = fo.ID;
                Bind();
            }
        }
예제 #9
0
        //Сохранение в базу
        protected void lbSaveAll_Click(object sender, EventArgs e)
        {
            if (Session["Abonent"] != null)
            {
                SessionAbonent sa = (SessionAbonent)Session["Abonent"];
                if (sa.Vodomer.Count == 0)
                {
                    SetMessege("Предупреждение", "Необходимо добавить минимум 1 водомер.");
                }
                else
                {
                    if (sa.Type == (short)Abonent.Corporate)
                    {
                        UAbonent   ua   = sa.UAbon;
                        UAbonentDO uado = new UAbonentDO();
                        int        uid  = uado.Create(ua);
                        if (uid > 0)
                        {
                            sa.UAbon.ID        = uid;
                            Session["Abonent"] = sa;
                            UOrder   uo   = new UOrder();
                            UOrderDO uodo = new UOrderDO();
                            uo.ActionType = "Поверка водомера.";
                            uo.UAbonentID = uid;
                            uo.UserID     = GetCurrentUser().ID;

                            int uoid = uodo.Create(uo);
                            if (uoid > 0)
                            {
                                hfOrder.Value = uoid.ToString();
                                UOrderDetails   uod   = new UOrderDetails();
                                UOrderDetailsDO uoddo = new UOrderDetailsDO();
                                VodomerDO       vdo   = new VodomerDO();
                                foreach (Vodomer v in sa.Vodomer)
                                {
                                    int vid = vdo.Create(v);
                                    uod.UOrderID   = uoid;
                                    uod.VodomerID  = vid;
                                    uod.StartValue = v.VodomerPreview.StartValue;
                                    int uodid = uoddo.Create(uod);
                                }
                            }
                        }
                    }
                    if (sa.Type == (short)Abonent.Private)
                    {
                        FAbonent   fa   = sa.FAbon;
                        FAbonentDO fado = new FAbonentDO();
                        int        fid  = fado.Create(fa);
                        if (fid > 0)
                        {
                            sa.FAbon.ID        = fid;
                            Session["Abonent"] = sa;
                            FOrder   fo   = new FOrder();
                            FOrderDO fodo = new FOrderDO();
                            fo.ActionType = "Поверка водомера.";
                            fo.FAbonentID = fid;
                            fo.UserID     = GetCurrentUser().ID;

                            int foid = fodo.Create(fo);
                            if (foid > 0)
                            {
                                hfOrder.Value = foid.ToString();
                                FOrderDetails   fod   = new FOrderDetails();
                                FOrderDetailsDO foddo = new FOrderDetailsDO();
                                VodomerDO       vdo   = new VodomerDO();
                                foreach (Vodomer v in sa.Vodomer)
                                {
                                    int vid = vdo.Create(v);
                                    fod.FOrderID   = foid;
                                    fod.VodomerID  = vid;
                                    fod.StartValue = v.VodomerPreview.StartValue;
                                    int uodid = foddo.Create(fod);
                                }
                            }
                        }
                    }
                    //SetMessege("Статус", "Абонент и водомер успешно внесены в базу.");
                    LoadStep3();
                }
            }
        }
예제 #10
0
        private void فاتورةمبيعاتToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FOrder f = new FOrder();

            f.ShowDialog();
        }
예제 #11
0
        public void Bind()
        {
            cbSeld.Checked = false;
            cbSeld.Enabled = true;
            cbPaid.Checked = false;
            cbPaid.Enabled = true;


            tbPaymentDay.Enabled = true;
            tbPaymentDay.Text    = DateTime.Now.ToShortDateString();

            FOrder          fo   = new FOrder();
            FOrderDO        fodo = new FOrderDO();
            UniversalEntity ue   = new UniversalEntity();

            ue = fodo.RetrieveFOrderById(_OrderID);
            if (ue.Count > 0)
            {
                fo = (FOrder)ue[0];

                /*if (!fo.IsPaid)
                 * {
                 *  btAct.Visible = false;
                 * }
                 * else
                 * {
                 *  btAct.Visible = true;
                 * }*/
                if (fo.DateOut != null)
                {
                    cbSeld.Checked = true;
                    cbSeld.Enabled = false;
                }
                if (fo.IsPaid)
                {
                    cbPaid.Checked = true;
                    cbPaid.Enabled = false;
                    if (fo.PaymentDay.HasValue)
                    {
                        tbPaymentDay.Text = fo.PaymentDay.Value.ToShortDateString();
                    }
                    tbPaymentDay.Enabled = false;
                }
            }

            hfODID.Value = _OrderID.ToString();
            StringBuilder sb   = new StringBuilder();
            FAbonent      fa   = new FAbonent();
            FAbonentDO    fado = new FAbonentDO();

            ue = fado.RetrieveByOrderID(_OrderID);
            if (ue.Count > 0)
            {
                fa = (FAbonent)ue[0];
                sb.AppendLine("<span>ФИО: " + fa.Surname + " " + fa.FirstName + " " + fa.LastName + "</span><br/>");
                sb.AppendLine("<span>Тел.: " + fa.Phone + "</span><br/>");
                sb.AppendLine("<span>Адрес: " + fa.Address + "</span><br/>");
                if (fa.NotPay)
                {
                    sb.AppendLine("<span>Без оплаты</span><br/>");
                }

                litAbonentInfo.Text = sb.ToString();
            }
        }
예제 #12
0
        private void Btn_AddSuppliers_ItemClick(object sender, ItemClickEventArgs e)
        {
            FOrder Order = new FOrder();

            Order.Show();
        }
예제 #13
0
        public static void GenerateFActSpecial(int id, int ULocationID)
        {
            UniversalEntity ue         = new UniversalEntity();
            string          header     = string.Empty;
            string          actNumber  = string.Empty;
            string          actNumber2 = string.Empty;

            FAbonentDO faDO = new FAbonentDO();

            ue = faDO.RetrieveByOrderID(id);
            FAbonent fa = new FAbonent();

            if (ue.Count > 0)
            {
                fa      = (FAbonent)ue[0];
                header += fa.Surname + " " + fa.FirstName + " " + fa.LastName + " \nадрес: " + fa.Address + "\nтел.: " + fa.Phone;
            }

            FOrder          fo    = new FOrder();
            FOrderDO        foDO  = new FOrderDO();
            FOrderDetailsDO fodDO = new FOrderDetailsDO();


            ue = foDO.RetrieveFOrderById(id);
            if (ue.Count > 0)
            {
                fo         = (FOrder)ue[0];
                actNumber  = "  г. Донецк            АКТ № " + fo.Prefix + fo.ID + " от ____________________" /*+ RuDateAndMoneyConverter.DateToTextLong(fo.DateIn)*/ + " г.";
                actNumber2 = "                             по договору (письму) №  " + fo.Prefix + fo.ID + " от ____________________" + /*RuDateAndMoneyConverter.DateToTextLong(fo.DateIn) +*/ " г.";
            }

            ue = fodDO.RetrieveFOrderDetailsByOrderID(id);

            InitializeWorkbookFActSpecial(); //InitializeWorkbook();
            ISheet sheet1 = hssfworkbook.GetSheet("s");

            //create cell on rows, since rows do already exist,it's not necessary to create rows again.
            sheet1.GetRow(2).GetCell(3).SetCellValue(header);
            sheet1.GetRow(32).GetCell(3).SetCellValue(header);
            sheet1.GetRow(9).GetCell(0).SetCellValue(actNumber);
            sheet1.GetRow(39).GetCell(0).SetCellValue(actNumber);
            sheet1.GetRow(11).GetCell(0).SetCellValue(actNumber2);
            //sheet1.GetRow(41).GetCell(0).SetCellValue(actNumber2);

            int    rowC = 44;
            int    row  = 14;
            double sum  = 0;

            int count = ue.Count;

            if (count <= 5)
            {
                CustomRetrieverDO crDO = new CustomRetrieverDO();
                ue = crDO.RetrieveFActByOrderID5Low(id);
                if (ue.Count > 0)
                {
                    for (int i = row; i < ue.Count + row; i++)
                    {
                        ArrayList al = (ArrayList)ue[i - row];
                        //FOrderDetailsAct u = (FOrderDetailsAct)fodal[i - row];

                        sheet1.GetRow(i).GetCell(0).SetCellValue(i - row + 1);
                        sheet1.GetRow(i).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString()));
                        sheet1.GetRow(i).GetCell(2).SetCellValue("калькуляция");
                        sheet1.GetRow(i).GetCell(3).SetCellValue("шт.");
                        sheet1.GetRow(i).GetCell(4).SetCellValue(al[4].ToString());
                        sheet1.GetRow(i).GetCell(5).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00"));
                        sheet1.GetRow(i).GetCell(6).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00"));


                        sum += Convert.ToDouble(al[3]);
                        rowC++;
                    }
                }
            }
            else
            {
                CustomRetrieverDO crDO = new CustomRetrieverDO();
                ue = crDO.RetrieveFActByOrderID5High(id);
                if (ue.Count > 0)
                {
                    for (int i = row; i < ue.Count + row; i++)
                    {
                        ArrayList al = (ArrayList)ue[i - row];
                        //FOrderDetailsAct u = (FOrderDetailsAct)fodal[i - row];

                        sheet1.GetRow(i).GetCell(0).SetCellValue(i - row + 1);
                        sheet1.GetRow(i).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера  D{0}", al[0].ToString()));
                        sheet1.GetRow(i).GetCell(2).SetCellValue("калькуляция");
                        sheet1.GetRow(i).GetCell(3).SetCellValue("шт.");
                        sheet1.GetRow(i).GetCell(4).SetCellValue(al[3].ToString());
                        sheet1.GetRow(i).GetCell(5).SetCellValue(Convert.ToDouble(al[1]).ToString("0.00"));
                        sheet1.GetRow(i).GetCell(6).SetCellValue(Convert.ToDouble(al[2]).ToString("0.00"));

                        sum += Convert.ToDouble(al[2]);
                        rowC++;
                    }
                }
            }
            sheet1.GetRow(19).GetCell(6).SetCellValue(sum.ToString("0.00"));
            sheet1.GetRow(20).GetCell(6).SetCellValue((sum / 100 * 20).ToString("0.00"));
            sheet1.GetRow(21).GetCell(6).SetCellValue((sum + (sum / 100 * 20)).ToString("0.00"));

            string tmp = string.Empty;

            tmp = sheet1.GetRow(29).GetCell(GetLetterNumber("c")).StringCellValue;

            string tmp1 = string.Empty;

            tmp1 = sheet1.GetRow(41).GetCell(GetLetterNumber("a")).StringCellValue;

            CustomRetrieverDO crdo = new CustomRetrieverDO();

            ue = crdo.RetrieveUserLocation(ULocationID);
            if (ue.Count > 0)
            {
                tmp1 = tmp1.Replace("257-42-61", (ue[0] as ArrayList)[2].ToString());
            }

            //tmp1 = tmp1.Replace("257-42-61", "");


            tmp = tmp.Replace("FIO", fa.Surname + " " + fa.FirstName + " " + fa.LastName);
            tmp = tmp.Replace("ADDRESS", fa.Address);
            tmp = tmp.Replace("PNONE", fa.Phone);
            tmp = tmp.Replace("DATE", DateTime.Now.ToString("dd MMMM yyyy"));
            tmp = tmp.Replace("NUMBER", fo.Prefix + fo.ID.ToString());
            tmp = tmp.Replace("TYPE", fo.ActionType);
            //tmp = tmp.Replace("SUM", sum.ToString("0.00"));
            //tmp = tmp.Replace("VAT", Utilities.GetVAT(sum).ToString("0.00"));
            tmp = tmp.Replace("ALL", (sum + Utilities.GetVAT(sum)).ToString("0.00"));



            sheet1.GetRow(41).GetCell(GetLetterNumber("a")).SetCellValue(tmp1);
            sheet1.GetRow(29).GetCell(GetLetterNumber("c")).SetCellValue(tmp);
            sheet1.GetRow(41).GetCell(GetLetterNumber("c")).SetCellValue(tmp);

            /*sheet1.GetRow(49).GetCell(6).SetCellValue(sum.ToString("0.00"));
             * sheet1.GetRow(50).GetCell(6).SetCellValue((sum / 100 * 20).ToString("0.00"));
             * sheet1.GetRow(51).GetCell(6).SetCellValue((sum + (sum / 100 * 20)).ToString("0.00"));*/

            //Force excel to recalculate all the formula while open
            sheet1.ForceFormulaRecalculation = true;

            WriteToFileFSpecial();
        }
예제 #14
0
        public void Bind()
        {
            EditorMode();
            cbSeld.Checked          = false;
            cbSeld.Enabled          = true;
            cbPaid.Checked          = false;
            cbPaid.Enabled          = true;
            cbRejectVodomer.Checked = false;
            cbRejectVodomer.Enabled = true;
            cbDefectVodomer.Checked = false;
            cbDefectVodomer.Enabled = true;


            tbPaymentDay.Enabled = true;
            tbPaymentDay.Text    = DateTime.Now.ToShortDateString();


            FOrder   fo   = new FOrder();
            FOrderDO fodo = new FOrderDO();
            //StringBuilder sbl = new StringBuilder();
            UniversalEntity ue = new UniversalEntity();

            ue = fodo.RetrieveFOrderById(_OrderID);
            if (ue.Count > 0)
            {
                fo = (FOrder)ue[0];

                /*if (!fo.IsPaid)
                 * {
                 *  btAct.Visible = false;
                 * }
                 * else
                 * {
                 *  btAct.Visible = true;
                 * }*/
                if (fo.DateOut != null)
                {
                    cbSeld.Checked = true;
                    cbSeld.Enabled = false;
                    cbPaid.Checked = true;
                    cbPaid.Enabled = false;
                }
                if (fo.IsPaid)
                {
                    cbPaid.Checked = true;
                    cbPaid.Enabled = false;
                    cbSeld.Checked = true;
                    cbSeld.Enabled = false;
                    if (fo.PaymentDay.HasValue)
                    {
                        tbPaymentDay.Text = fo.PaymentDay.Value.ToShortDateString();
                    }
                    tbPaymentDay.Enabled = false;
                }
                if (fo.DefectVodomer)
                {
                    cbDefectVodomer.Checked = true;
                    cbDefectVodomer.Enabled = false;
                }
            }


            hfODID.Value = _OrderID.ToString();
            StringBuilder sb   = new StringBuilder();
            FAbonent      fa   = new FAbonent();
            FAbonentDO    fado = new FAbonentDO();

            ue = fado.RetrieveByOrderID(_OrderID);
            if (ue.Count > 0)
            {
                fa = (FAbonent)ue[0];
                if (fa.NotPay)
                {
                    cbPaid.Enabled   = false;
                    btActRub.Enabled = false;
                    //btPay.Enabled = false;
                    //btOrder.Enabled = false;
                    //btOrderCheck.Enabled = false;
                    btActCheckRub.Enabled = false;
                    //btWithdrawalAct.Enabled = false;
                }
                sb.AppendLine("<span>ФИО: " + fa.Surname + " " + fa.FirstName + " " + fa.LastName + "</span><br/>");
                sb.AppendLine("<span>номер по журналу: " + fa.PhysicalNumberJournal + "</span><br/>");
                sb.AppendLine("<span>Тел.: " + fa.Phone + "</span><br/>");
                sb.AppendLine("<span>Адрес: " + fa.Address + "</span><br/>");
                if (fa.NotPay)
                {
                    sb.AppendLine("<span style=\"color:red;font-size:18px;\">Без оплаты</span><br/>");
                }



                litAbonentInfo.Text = sb.ToString();
            }
        }
예제 #15
0
        private void tileItem14_ItemClick(object sender, DevExpress.XtraEditors.TileItemEventArgs e)
        {
            FOrder Order = new FOrder();

            Order.Show();
        }
예제 #16
0
 void addParameters(FOrder ent)
 {
     AddParametersToSqlCommand(ent, ref sc);
 }
예제 #17
0
 void AddParametersToSqlCommand(FOrder ent, ref SqlCommand sc)
 {
     sc.Parameters.Add("@FAbonentID", ent.FAbonentID);
     sc.Parameters.Add("@ActionType", ent.ActionType);
     sc.Parameters.Add("@UserID", ent.UserID);
 }
예제 #18
0
        //Сохранение в базу
        protected void lbSaveAll_Click(object sender, EventArgs e)
        {
            if (Session["Abonent"] != null)
            {
                SessionAbonent sa = (SessionAbonent)Session["Abonent"];
                if (sa.Vodomer.Count == 0)
                {
                    radWM.RadAlert("Необходимо добавить минимум 1 водомер.", null, null, "Предупреждение", "");
                }
                else
                {
                    if (sa.Type == (short)Abonent.Corporate)
                    {
                        UAbonent   ua   = sa.UAbon;
                        UAbonentDO uado = new UAbonentDO();
                        int        uid  = uado.Create(ua);
                        if (uid > 0)
                        {
                            sa.UAbon.ID        = uid;
                            Session["Abonent"] = sa;
                            UOrder   uo   = new UOrder();
                            UOrderDO uodo = new UOrderDO();
                            uo.ActionType = "Определения метрологических характеристик водомера";
                            uo.UAbonentID = uid;
                            uo.UserID     = GetCurrentUser().ID;

                            int uoid = uodo.Create(uo);
                            if (uoid > 0)
                            {
                                hfOrder.Value = uoid.ToString();
                                UOrderDetails   uod   = new UOrderDetails();
                                UOrderDetailsDO uoddo = new UOrderDetailsDO();
                                VodomerDO       vdo   = new VodomerDO();
                                foreach (Vodomer v in sa.Vodomer)
                                {
                                    int vid = vdo.Create1(v);
                                    uod.UOrderID   = uoid;
                                    uod.VodomerID  = vid;
                                    uod.StartValue = v.VodomerPreview.StartValue;
                                    int uodid = uoddo.Create(uod);
                                }
                                Response.Redirect("UJournal.aspx?id=" + uoid.ToString());
                            }
                        }
                    }
                    if (sa.Type == (short)Abonent.Private)
                    {
                        FAbonent   fa   = sa.FAbon;
                        FAbonentDO fado = new FAbonentDO();
                        int        fid  = fado.Create(fa);
                        if (fid > 0)
                        {
                            sa.FAbon.ID        = fid;
                            Session["Abonent"] = sa;
                            FOrder   fo   = new FOrder();
                            FOrderDO fodo = new FOrderDO();
                            fo.ActionType = "Определения метрологических характеристик водомера ";
                            fo.FAbonentID = fid;
                            fo.UserID     = GetCurrentUser().ID;

                            int foid = fodo.Create(fo);
                            if (foid > 0)
                            {
                                hfOrder.Value = foid.ToString();
                                FOrderDetails   fod   = new FOrderDetails();
                                FOrderDetailsDO foddo = new FOrderDetailsDO();
                                VodomerDO       vdo   = new VodomerDO();
                                foreach (Vodomer v in sa.Vodomer)
                                {
                                    int vid = vdo.Create1(v);
                                    fod.FOrderID   = foid;
                                    fod.VodomerID  = vid;
                                    fod.StartValue = v.VodomerPreview.StartValue;
                                    int uodid = foddo.Create(fod);
                                }
                                Response.Redirect("FJournal.aspx?id=" + foid.ToString());
                            }
                        }
                    }
                    // LoadStep3();
                }
            }
        }
예제 #19
0
        public static void GenerateFAct(int id)
        {
            UniversalEntity ue         = new UniversalEntity();
            string          header     = string.Empty;
            string          actNumber  = string.Empty;
            string          actNumber2 = string.Empty;

            FAbonentDO faDO = new FAbonentDO();

            ue = faDO.RetrieveByOrderID(id);
            if (ue.Count > 0)
            {
                FAbonent fa = (FAbonent)ue[0];
                header += fa.Surname + " " + fa.FirstName + " " + fa.LastName + " \nадрес: " + fa.Address + "\nтел.: " + fa.Phone;
            }

            FOrder          fo    = new FOrder();
            FOrderDO        foDO  = new FOrderDO();
            FOrderDetailsDO fodDO = new FOrderDetailsDO();

            ue = foDO.RetrieveFOrderById(id);
            if (ue.Count > 0)
            {
                fo         = (FOrder)ue[0];
                actNumber  = "  г. Донецк            АКТ № " + fo.Prefix + fo.ID + " от " + RuDateAndMoneyConverter.DateToTextLong(fo.DateIn) + " г.";
                actNumber2 = "                             по договору (письму) №  " + fo.Prefix + fo.ID + " от " + RuDateAndMoneyConverter.DateToTextLong(fo.DateIn) + " г.";
            }

            ue = fodDO.RetrieveFOrderDetailsByOrderID(id);

            InitializeWorkbookFAct(); //InitializeWorkbook();
            ISheet sheet1 = hssfworkbook.GetSheet("s");

            //create cell on rows, since rows do already exist,it's not necessary to create rows again.
            sheet1.GetRow(2).GetCell(3).SetCellValue(header);
            sheet1.GetRow(32).GetCell(3).SetCellValue(header);
            sheet1.GetRow(9).GetCell(0).SetCellValue(actNumber);
            sheet1.GetRow(39).GetCell(0).SetCellValue(actNumber);
            sheet1.GetRow(11).GetCell(0).SetCellValue(actNumber2);
            sheet1.GetRow(41).GetCell(0).SetCellValue(actNumber2);

            int    rowC = 44;
            int    row  = 14;
            double sum  = 0;

            int count = ue.Count;

            if (count <= 5)
            {
                CustomRetrieverDO crDO = new CustomRetrieverDO();
                ue = crDO.RetrieveFActByOrderID5Low(id);
                if (ue.Count > 0)
                {
                    for (int i = row; i < ue.Count + row; i++)
                    {
                        ArrayList al = (ArrayList)ue[i - row];
                        //FOrderDetailsAct u = (FOrderDetailsAct)fodal[i - row];

                        sheet1.GetRow(i).GetCell(0).SetCellValue(i - row + 1);
                        sheet1.GetRow(i).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера  D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString()));
                        sheet1.GetRow(i).GetCell(2).SetCellValue("калькуляция");
                        sheet1.GetRow(i).GetCell(3).SetCellValue("шт.");
                        sheet1.GetRow(i).GetCell(4).SetCellValue(al[4].ToString());
                        sheet1.GetRow(i).GetCell(5).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00"));
                        sheet1.GetRow(i).GetCell(6).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00"));


                        sheet1.GetRow(rowC).GetCell(0).SetCellValue(i - row + 1);
                        sheet1.GetRow(rowC).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера  D{0}, {1}, {2}", al[0].ToString(), al[1].ToString(), al[2].ToString()));
                        sheet1.GetRow(rowC).GetCell(2).SetCellValue("калькуляция");
                        sheet1.GetRow(rowC).GetCell(3).SetCellValue("шт.");
                        sheet1.GetRow(rowC).GetCell(4).SetCellValue(al[4].ToString());
                        sheet1.GetRow(rowC).GetCell(5).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00"));
                        sheet1.GetRow(rowC).GetCell(6).SetCellValue(Convert.ToDouble(al[3]).ToString("0.00"));

                        sum += Convert.ToDouble(al[3]);
                        rowC++;
                    }
                }
            }
            else
            {
                CustomRetrieverDO crDO = new CustomRetrieverDO();
                ue = crDO.RetrieveFActByOrderID5High(id);
                if (ue.Count > 0)
                {
                    for (int i = row; i < ue.Count + row; i++)
                    {
                        ArrayList al = (ArrayList)ue[i - row];
                        //FOrderDetailsAct u = (FOrderDetailsAct)fodal[i - row];

                        sheet1.GetRow(i).GetCell(0).SetCellValue(i - row + 1);
                        sheet1.GetRow(i).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера  D{0}", al[0].ToString()));
                        sheet1.GetRow(i).GetCell(2).SetCellValue("калькуляция");
                        sheet1.GetRow(i).GetCell(3).SetCellValue("шт.");
                        sheet1.GetRow(i).GetCell(4).SetCellValue(al[3].ToString());
                        sheet1.GetRow(i).GetCell(5).SetCellValue(Convert.ToDouble(al[1]).ToString("0.00"));
                        sheet1.GetRow(i).GetCell(6).SetCellValue(Convert.ToDouble(al[2]).ToString("0.00"));


                        sheet1.GetRow(rowC).GetCell(0).SetCellValue(i - row + 1);
                        sheet1.GetRow(rowC).GetCell(1).SetCellValue(string.Format("Определения метрологических характеристик водомера  D{0}", al[0].ToString()));
                        sheet1.GetRow(rowC).GetCell(2).SetCellValue("калькуляция");
                        sheet1.GetRow(rowC).GetCell(3).SetCellValue("шт.");
                        sheet1.GetRow(rowC).GetCell(4).SetCellValue(al[3].ToString());
                        sheet1.GetRow(rowC).GetCell(5).SetCellValue(Convert.ToDouble(al[1]).ToString("0.00"));
                        sheet1.GetRow(rowC).GetCell(6).SetCellValue(Convert.ToDouble(al[2]).ToString("0.00"));

                        sum += Convert.ToDouble(al[2]);
                        rowC++;
                    }
                }
            }



            sheet1.GetRow(19).GetCell(6).SetCellValue(sum.ToString("0.00"));
            sheet1.GetRow(20).GetCell(6).SetCellValue((sum / 100 * 20).ToString("0.00"));
            sheet1.GetRow(21).GetCell(6).SetCellValue((sum + (sum / 100 * 20)).ToString("0.00"));

            sheet1.GetRow(49).GetCell(6).SetCellValue(sum.ToString("0.00"));
            sheet1.GetRow(50).GetCell(6).SetCellValue((sum / 100 * 20).ToString("0.00"));
            sheet1.GetRow(51).GetCell(6).SetCellValue((sum + (sum / 100 * 20)).ToString("0.00"));

            //Force excel to recalculate all the formula while open
            sheet1.ForceFormulaRecalculation = true;

            WriteToFileF();
        }