Пример #1
0
        protected void btnSayacKaydet_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(hdnSayacID.Value))
            {
                if (grdMasraf.SelectedValue != null)
                {
                    int makineid = Int32.Parse(Request.QueryString["makineid"]);

                    int    id    = Convert.ToInt32(grdMasraf.SelectedValue);
                    string birim = grdMasraf.SelectedRow.Cells[4].Text;
                    using (radiusEntities dc = MyContext.Context(KullaniciIslem.firma()))
                    {
                        decimal     sayac       = Decimal.Parse(txtSayac.Text);
                        decimal     sayac_alarm = Decimal.Parse(txtSayacAlarm.Text);
                        MakineIslem m           = new MakineIslem(dc);
                        bool        tamam       = m.sayacekle(makineid, id, sayac, birim, sayac_alarm);
                        if (tamam == true)
                        {
                            m.sayacdelete(id);
                            string basS = datetimepicker6.Value;
                            string sonS = datetimepicker7.Value;

                            ortak(dc, basS, sonS);

                            System.Text.StringBuilder sb = new System.Text.StringBuilder();
                            sb.Append(@"<script type='text/javascript'>");
                            sb.Append(" alertify.success('Sayaç kaydedildi');");
                            sb.Append("$('#yeniSayacModal').modal('hide');");
                            sb.Append(@"</script>");
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "yeniSayaceModalScript", sb.ToString(), false);
                        }
                        else
                        {
                            System.Text.StringBuilder sb = new System.Text.StringBuilder();
                            sb.Append(@"<script type='text/javascript'>");
                            sb.Append(" alertify.error('Bu sayaç tanımı zaten yapılmış');");
                            sb.Append("$('#yeniSayacModal').modal('hide');");
                            sb.Append(@"</script>");
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "yeniSayaceModalScript", sb.ToString(), false);
                        }
                    }
                }
            }
            else
            {
                int id = Int32.Parse(hdnSayacID.Value);

                using (radiusEntities dc = MyContext.Context(KullaniciIslem.firma()))
                {
                    MakineIslem m = new MakineIslem(dc);
                    m.sayacupdate(id, Int32.Parse(txtSayac.Text));
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(@"<script type='text/javascript'>");
                    sb.Append(" alertify.success('Sayaç kaydedildi');");
                    sb.Append("$('#yeniSayacModal').modal('hide');");
                    sb.Append(@"</script>");
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "yeniSayaceModalScript", sb.ToString(), false);
                }
            }
        }
Пример #2
0
        protected void grdSayac_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("del"))
            {
                string        confirmValue = Request.Form["confirm_value"];
                List <string> liste        = confirmValue.Split(new char[] { ',' }).ToList();
                int           sayimiz      = liste.Count - 1;
                string        deger        = liste[sayimiz];

                if (deger == "Yes")
                {
                    int id = Convert.ToInt32(e.CommandArgument);
                    using (radiusEntities dc = MyContext.Context(KullaniciIslem.firma()))
                    {
                        MakineIslem s = new MakineIslem(dc);
                        s.sayacdelete(id);
                        string basS = datetimepicker6.Value;
                        string sonS = datetimepicker7.Value;

                        ortak(dc, basS, sonS);
                    }


                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(@"<script type='text/javascript'>");
                    sb.Append(" alertify.error('Kayıt silindi!');");

                    sb.Append(@"</script>");
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditHideModalScript3", sb.ToString(), false);
                }


                else
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(@"<script type='text/javascript'>");
                    sb.Append(" alertify.error('" + deger + "');");

                    sb.Append(@"</script>");
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditHideModalScript3", sb.ToString(), false);
                }
            }
            else if (e.CommandName.Equals("duzenle"))
            {
                string[] arg = new string[2];
                arg = e.CommandArgument.ToString().Split(';');

                int         index = Convert.ToInt32(arg[1]);
                GridViewRow row   = grdSayac.Rows[index];
                string      sayac = row.Cells[2].Text;

                hdnSayacID.Value = Convert.ToString(arg[0]);
                txtSayac.Text    = sayac;

                grdMasraf.SelectedIndex = -1;
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$('#yeniSayacModal').modal('show');");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "yeniSayaceModalScript", sb.ToString(), false);
            }
        }