Ejemplo n.º 1
0
        private void SaveEditItem()
        {
            string mobil  = string.Empty
            , sopir       = string.Empty
            , keterangan  = null;
            int kernetid  = -1
            , custid      = -1
            , sopirid     = -1
            , mobilid     = -1
            , kotaid      = -1
            , salesid     = -1
            , custtypeid  = -1
            , transtypeid = -1;

            transtypeid = int.Parse(rddTipe.SelectedValue.ToString());
            kotaid      = int.Parse(rddTujuan.SelectedValue.ToString());
            salesid     = int.Parse(rddSales.SelectedValue.ToString());
            if (chkAntar.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
            {
                sopirid  = int.Parse(rddSopir.SelectedValue.ToString());
                mobilid  = int.Parse(rddMobil.SelectedValue.ToString());
                kernetid = int.Parse(rddKernet.SelectedValue.ToString());
            }
            else
            {
                sopir = txtSopir.Text;
                mobil = txtMobil.Text;
            }

            switch (rddTipe.Text.ToLower())
            {
            case "pelanggan":
                custid     = int.Parse(rddPel.SelectedValue.ToString());
                custtypeid = int.Parse(rddPel.Tag.ToString());
                break;

            case "sales":
                custid     = int.Parse(rddSales.SelectedValue.ToString());
                custtypeid = 2;
                break;

            case "staff":
            case "satpam":
            case "pegawai":
                custid     = int.Parse(rddPel.SelectedValue.ToString());
                custtypeid = int.Parse(rddPel.Tag.ToString());
                break;

            case "contoh":
                break;
            }
            using (sinarekDataSetTableAdapters.logproductTableAdapter tbl = new sinarekDataSetTableAdapters.logproductTableAdapter())
            {
                //Update SJ
                tbl.UpdateSJ(tanggalDateTimePicker.Value
                             , transtypeid
                             , custtypeid
                             , custid
                             , kernetid
                             , kotaid
                             , sopirid
                             , mobil
                             , mobilid
                             , salesid
                             , sopir
                             , keterangan
                             , NBConfig.ValidUserName
                             , logid_).ToString();
            }
            try
            {
                //logdetailTableAdapter.Update(this.sinarekDataSet.logdetail);
                //insert new records
                using (sinarekDataSetTableAdapters.logdetailTableAdapter tbl = new sinarekDataSetTableAdapters.logdetailTableAdapter())
                {
                    foreach (GridViewRowInfo item in radGridView1.Rows)
                    {
                        if (item.Cells["detailid"].Value.ToString() == "-1")
                        {
                            tbl.pInsertLogDetail(int.Parse(logid_.ToString())
                                                 , int.Parse(item.Cells["productid"].Value.ToString())
                                                 , decimal.Parse(item.Cells["quantity"].Value.ToString())
                                                 , int.Parse(item.Cells["custtypetoid"].Value.ToString())
                                                 , int.Parse(item.Cells["custtypeid"].Value.ToString())
                                                 , int.Parse(item.Cells["status"].Value.ToString())
                                                 , (item.Cells["keterangan"].Value == null ? "" : item.Cells["keterangan"].Value.ToString())
                                                 , NBConfig.ValidUserName);
                        }
                        else
                        {
                            tbl.UpdateItem(int.Parse(item.Cells["productid"].Value.ToString())
                                           , int.Parse(item.Cells["custtypeid"].Value.ToString())
                                           , int.Parse(item.Cells["custtypetoid"].Value.ToString())
                                           , (item.Cells["keterangan"].Value == null ? "" : item.Cells["keterangan"].Value.ToString())
                                           , decimal.Parse(item.Cells["quantity"].Value.ToString())
                                           , NBConfig.ValidUserName, long.Parse(item.Cells["detailid"].Value.ToString()));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }

            helper.NotifMessage("SJ sudah tersimpan!");
        }
Ejemplo n.º 2
0
        private void SaveEditItem()
        {
            //Can only update items / kernet / sopir
            string iLogID  = string.Empty;
            string mobil   = string.Empty
            , sopir        = string.Empty
            , keterangan   = null;
            int kernetid   = -1
            , sopirid      = -1
            , mobilid      = -1
            , kotaid       = -1
            , salesid      = -1
            , custtypetoid = -1;

            custtypetoid = int.Parse(rddTipe.SelectedValue.ToString());
            kotaid       = int.Parse(rddTujuan.SelectedValue.ToString());
            salesid      = int.Parse(rddPelSales.SelectedValue.ToString());

            switch (rddTipe.Text.ToLower())
            {
            case "pelanggan":
                if (chkAntar.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    sopirid  = int.Parse(rddPelSopir.SelectedValue.ToString());
                    mobilid  = int.Parse(rddPelMobil.SelectedValue.ToString());
                    kernetid = int.Parse(rddPelKernet.SelectedValue.ToString());
                }
                else
                {
                    sopir = txtSopir.Text;
                    mobil = txtMobil.Text;
                }
                break;

            case "sales":
                salesid  = int.Parse(rddSales.SelectedValue.ToString());
                sopirid  = int.Parse(rddSopir.SelectedValue.ToString());
                mobilid  = int.Parse(rddMobil.SelectedValue.ToString());
                kernetid = int.Parse(rddKernet.SelectedValue.ToString());
                break;

            case "staff":
            case "satpam":
            case "buruh":
            case "contoh":
                break;
            }
            using (sinarekDataSetTableAdapters.logproductTableAdapter tbl = new sinarekDataSetTableAdapters.logproductTableAdapter())
            {
                //Update SJ
                tbl.UpdateSJ(tanggalDateTimePicker.Value
                             , kernetid
                             , kotaid
                             , sopirid
                             , mobil
                             , mobilid
                             , salesid
                             , sopir
                             , keterangan
                             , NBConfig.ValidUserName
                             , logid_).ToString();
            }
            using (sinarekDataSetTableAdapters.logdetailTableAdapter tbl = new sinarekDataSetTableAdapters.logdetailTableAdapter())
            {
                foreach (GridViewRowInfo item in radGridView1.Rows)
                {
                    if (item.Cells["detailid"].Value != null)
                    {
                        //Update
                        tbl.UpdateItem(int.Parse(item.Cells["productid"].Value.ToString())
                                       , int.Parse(item.Cells["custtypeid"].Value.ToString())
                                       , custtypetoid
                                       , ""
                                       , decimal.Parse(item.Cells["quantity"].Value.ToString())
                                       , NBConfig.ValidUserName
                                       , long.Parse(item.Cells["detailid"].Value.ToString()));
                    }
                    else
                    {
                        //Insert
                        tbl.pInsertLogDetail(int.Parse(logid_.ToString())
                                             , int.Parse(item.Cells["productid"].Value.ToString())
                                             , decimal.Parse(item.Cells["quantity"].Value.ToString())
                                             , custtypetoid
                                             , int.Parse(item.Cells["custtypeid"].Value.ToString())
                                             , 1
                                             , NBConfig.ValidUserName);
                    }
                }
            }
            helper.NotifMessage("SJ sudah tersimpan!");
        }