public string GetweightmachinByCode(string code)
        {
            WeightMachineMaster _wm = _wrepo.GetMachineMasterByCode(code.ToLower());
            string myjsonresult     = new JavaScriptSerializer().Serialize(_wm);

            return(myjsonresult);
        }
Ejemplo n.º 2
0
        //Get:Weight Machine Master by MachineId
        public WeightMachineMaster GetMachineMaster_ByMachineId(string MachineId)
        {
            WeightMachineMaster machine = (from t in db.WeightMachineMasters
                                           where t.MachineId == MachineId && t.IsDeleted == false
                                           select t).FirstOrDefault();

            return(machine);
        }
        public string Check_WeightMachineMaster(string machineid)
        {
            string json           = string.Empty;
            WeightMachineMaster m = _wrepo.GetMachineMaster_ByMachineId(machineid.ToLower());

            if (m != null)
            {
                json = new JavaScriptSerializer().Serialize(m);
            }
            return(json);
        }
Ejemplo n.º 4
0
        //Add:New Weight Machine Master record
        public bool Add_WeightMachineMaster(WeightMachineMaster wt)
        {
            bool status = false;

            if (wt != null)
            {
                db.WeightMachineMasters.InsertOnSubmit(wt);
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
Ejemplo n.º 5
0
        //Delete:Weight Machine Master
        public bool Delete_WeightMachineMaster(int id)
        {
            bool status           = false;
            WeightMachineMaster w = db.WeightMachineMasters.FirstOrDefault(x => x.Id == id && x.IsDeleted == false);

            if (w != null)
            {
                w.IsDeleted = true;
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
 //Add:New Record
 private void Add()
 {
     try
     {
         var _data = _repo.GetMachineMaster_ByMachineId(txtMachinId.Text.Trim());
         if (_data != null)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same Machin Id Exist Please Try Again');", true);
         }
         else
         {
             WeightMachineMaster wm = new WeightMachineMaster();
             wm.PlantCodeId       = ddlPlantId.SelectedValue;
             wm.MachineId         = txtMachinId.Text;
             wm.Capacity          = txtCapacity.Text.ToString() + ddlcapacityuom.SelectedValue.ToString();
             wm.Resolution        = txtResolution.Text.ToString() + ddlresolutionuom.SelectedValue.ToString();
             wm.Model             = txtModel.Text.ToString();
             wm.PlatformSize      = txtPlatformsize.Text.ToString();
             wm.MachineNo         = txtmachinno.Text.ToString();
             wm.Indicator         = txtindicator.Text.ToString();
             wm.LCType            = txtlctype.Text.ToString();
             wm.NoOfLoadCells     = txtnoofloadcells.Text.ToString();
             wm.LoadCellSerialNos = txtnoofloadcells.Text.ToString();
             wm.EquipmentId       = Convert.ToInt32(txtequipment.Text);
             wm.InvoiceNo         = txtinvoiceno.Text.ToString();
             DateTime dispatchdate = DateTime.ParseExact(txtdispatchdate.Text, "dd/MM/yyyy", new CultureInfo("en-GB"));
             wm.DespatchDate = dispatchdate;
             DateTime InstallationDate = DateTime.ParseExact(txtinstallationdate.Text, "dd/MM/yyyy", new CultureInfo("en-GB"));
             wm.InstallationDate = InstallationDate;
             DateTime WarrentyUpto = DateTime.ParseExact(txtwarrantyupto.Text, "dd/MM/yyyy", new CultureInfo("en-GB"));
             wm.WarrentyUpto           = WarrentyUpto;
             wm.ReasonWarrentyUptoDate = txtrowud.Text.ToString();
             wm.WeighingUnit           = this.ddlcapacityuom.Text.Trim().ToString();
             wm.IsDeleted = false;
             if (_repo.Add_WeightMachineMaster(wm))
             {
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Save Successfully');", true);
                 HtmlMeta meta = new HtmlMeta();
                 meta.HttpEquiv = "Refresh";
                 meta.Content   = "1;url=AddEdit.aspx";
                 this.Page.Controls.Add(meta);
             }
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('" + ex.Message.ToString() + "');", true);
     }
 }
        //Update:Weight Machine Master
        private void Edit()
        {
            int id = Convert.ToInt32(Request.QueryString["Id"].ToString());

            try
            {
                var _data = _repo.GetMachineMasters_List().Where(x => x.MachineId == txtMachinId.Text && x.Id != id && x.IsDeleted == false).FirstOrDefault();
                if (_data != null)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same Machin Id Exist! Please try again');", true);
                }
                else
                {
                    WeightMachineMaster _dt = db.WeightMachineMasters.Where(x => x.Id == id && x.IsDeleted == false).FirstOrDefault();
                    _dt.MachineId              = txtMachinId.Text.ToString();
                    _dt.PlantCodeId            = ddlPlantId.SelectedValue.ToString();
                    _dt.Capacity               = txtCapacity.Text.ToString() + ddlcapacityuom.Text.ToString();
                    _dt.Resolution             = txtResolution.Text.ToString() + ddlresolutionuom.Text.ToString();
                    _dt.Model                  = txtModel.Text.ToString();
                    _dt.PlatformSize           = txtPlatformsize.Text.ToString();
                    _dt.MachineNo              = txtmachinno.Text.ToString();
                    _dt.Indicator              = txtindicator.Text.ToString();
                    _dt.LCType                 = txtlctype.Text.ToString();
                    _dt.NoOfLoadCells          = txtnoofloadcells.Text.ToString();
                    _dt.LoadCellSerialNos      = txtlcsn.Text.ToString();
                    _dt.EquipmentId            = Convert.ToInt32(txtequipment.Text);
                    _dt.InvoiceNo              = txtinvoiceno.Text.ToString();
                    _dt.DespatchDate           = Convert.ToDateTime(txtdispatchdate.Text);
                    _dt.InstallationDate       = Convert.ToDateTime(txtinstallationdate.Text);
                    _dt.WarrentyUpto           = Convert.ToDateTime(txtwarrantyupto.Text);
                    _dt.ReasonWarrentyUptoDate = txtrowud.Text.ToString();
                    _dt.WeighingUnit           = this.ddlcapacityuom.Text.Trim().ToString();
                    db.SubmitChanges();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Record Updated Successfully');", true);
                    HtmlMeta meta = new HtmlMeta();
                    meta.HttpEquiv = "Refresh";
                    meta.Content   = "1;url=AddEdit.aspx?id=" + id;
                    this.Page.Controls.Add(meta);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('" + ex.Message.ToString() + "');", true);
            }
        }
        //Get:Previous record
        protected void Previous_Record_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
            WeightMachineMaster next = null;

            try
            {
                next = _repo.GetMachineMasters_List().Where(x => x.Id < id && x.IsDeleted == false).OrderByDescending(i => i.Id).FirstOrDefault();
            }
            catch
            {
            }
            if (next != null)
            {
                Response.Redirect("AddEdit.aspx?id=" + next.Id.ToString());
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('No more records founds.')", true);
            }
        }
        //Get:Weight Machine Master for edit
        private void GetWTMachinMasterForEdit()
        {
            if (Request.QueryString["Id"] != null)
            {
                txtMachinId.Enabled = false;
                ddlPlantId.Enabled  = false;
                divoptions.Style.Add("display", "block");
                int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
                WeightMachineMaster _wmm = _repo.Get_WeightMachineMasterById(id);
                if (_wmm != null)
                {
                    ddlPlantId.SelectedValue = _wmm.PlantCodeId.ToString();
                    txtMachinId.Text         = _wmm.MachineId.ToString();

                    txtCapacity.Text             = _repo.Get_Number(_wmm.Capacity);
                    ddlcapacityuom.SelectedValue = _repo.Get_String(_wmm.Capacity);



                    txtResolution.Text             = _repo.Get_Number(_wmm.Resolution);
                    ddlresolutionuom.SelectedValue = _repo.Get_String(_wmm.Resolution);

                    txtModel.Text            = _wmm.Model.ToString();
                    txtPlatformsize.Text     = _wmm.PlatformSize.ToString();
                    txtmachinno.Text         = _wmm.MachineNo.ToString();
                    txtindicator.Text        = _wmm.Indicator.ToString();
                    txtlctype.Text           = _wmm.LCType.ToString();
                    txtnoofloadcells.Text    = _wmm.NoOfLoadCells.ToString();
                    txtlcsn.Text             = _wmm.LoadCellSerialNos.ToString();
                    txtequipment.Text        = _wmm.EquipmentId.ToString();
                    txtinvoiceno.Text        = _wmm.InvoiceNo.ToString();
                    txtdispatchdate.Text     = _wmm.DespatchDate.ToString();
                    txtinstallationdate.Text = _wmm.InstallationDate.ToString();
                    txtwarrantyupto.Text     = _wmm.WarrentyUpto.ToString();
                    txtrowud.Text            = _wmm.ReasonWarrentyUptoDate.ToString();
                    this.ddlcapacityuom.Text = _wmm.WeighingUnit.ToString();
                }
            }
        }
        //Save:Excel file data to the server
        public string SaveDataToServer(DataSet ds)
        {
            string result = string.Empty;

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                string    connection = ConfigurationManager.ConnectionStrings["AveryDBConnectionString"].ConnectionString;
                DataTable dt         = ds.Tables[0];
                int       _failed    = 0;
                int       _success   = 0;
                int       _update    = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        string _PlantCode           = dr["Plant Code"].ToString();
                        string _MachineId           = dr["Machine Id"].ToString();
                        string _IPPort              = dr["IP Port"].ToString();
                        string _PortNo              = dr["Port No"].ToString();
                        string _ModeOfComs          = dr["Mode Of Coms"].ToString();
                        string _StabilityNos        = dr["Stability Nos"].ToString();
                        string _StabilityRange      = dr["Stability Range"].ToString();
                        int    _ZeroInterlock       = Convert.ToInt32(dr["Zero Interlock"]);
                        string _ZeroInterlockRange  = dr["Zero Interlock Range"].ToString();
                        string _TransactionNoPrefix = dr["Transaction No Prefix"].ToString();
                        int    _TareCheck           = Convert.ToInt32(dr["Tare Check"]);
                        int    _StoredTare          = Convert.ToInt32(dr["Stored Tare"]);
                        var    data = db.tblMachineWorkingParameters.Where(x => x.PlantCode == _PlantCode && x.MachineId == _MachineId && x.IsDeleted == false).FirstOrDefault();
                        if (data != null)
                        {
                            if (string.IsNullOrEmpty(_IPPort) && string.IsNullOrEmpty(_PortNo) && string.IsNullOrEmpty(_ModeOfComs))
                            {
                                _failed++;
                            }
                            else
                            {
                                data.PlantCode           = _PlantCode;
                                data.MachineId           = _MachineId;
                                data.IPPort              = _IPPort;
                                data.PortNo              = _PortNo;
                                data.StabilityNos        = _StabilityNos;
                                data.StabilityRange      = _StabilityRange;
                                data.TransactionNoPrefix = _TransactionNoPrefix;
                                data.ZeroInterlock       = _ZeroInterlock;
                                data.ZeroInterlockRange  = _ZeroInterlockRange;
                                data.ModeOfComs          = _ModeOfComs;
                                data.TareCheck           = _TareCheck;
                                data.StoredTare          = _StoredTare;
                                db.SubmitChanges();
                                _update++;
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(_PlantCode) && !string.IsNullOrEmpty(_MachineId) && !string.IsNullOrEmpty(_ModeOfComs) && !string.IsNullOrEmpty(_IPPort) && !string.IsNullOrEmpty(_PortNo))
                            {
                                PlantMaster         _plantmaster   = db.PlantMasters.Where(x => x.PlantCode == _PlantCode && x.IsDeleted == false).FirstOrDefault();
                                WeightMachineMaster _machinemaster = db.WeightMachineMasters.Where(x => x.MachineId == _MachineId && x.IsDeleted == false).FirstOrDefault();
                                if (_plantmaster != null && _machinemaster != null)
                                {
                                    tblMachineWorkingParameter _machineparameter = db.tblMachineWorkingParameters.Where(x => x.PlantCode == _PlantCode && x.MachineId == _MachineId && x.IsDeleted == false).FirstOrDefault();
                                    if (_machineparameter != null)
                                    {
                                        _failed++;
                                    }
                                    else
                                    {
                                        tblMachineWorkingParameter t = new tblMachineWorkingParameter();
                                        t.PlantCode           = _PlantCode;
                                        t.MachineId           = _MachineId;
                                        t.IPPort              = _IPPort;
                                        t.PortNo              = _PortNo;
                                        t.StabilityNos        = _StabilityNos;
                                        t.StabilityRange      = _StabilityRange;
                                        t.TransactionNoPrefix = _TransactionNoPrefix;
                                        t.ZeroInterlock       = _ZeroInterlock;
                                        t.ZeroInterlockRange  = _ZeroInterlockRange;
                                        t.TareCheck           = _TareCheck;
                                        t.StoredTare          = _StoredTare;
                                        t.ModeOfComs          = _ModeOfComs;
                                        db.tblMachineWorkingParameters.InsertOnSubmit(t);
                                        db.SubmitChanges();
                                        _success++;
                                    }
                                }
                                else
                                {
                                    _failed++;
                                }
                            }
                            else
                            {
                                _failed++;
                            }
                        }
                    }
                    catch
                    {
                        _failed++;
                    }
                }
                result = "New Added: " + _success + "  Updated:  " + _update + "  Failed:  " + _failed + "";
            }
            return(result);
        }
Ejemplo n.º 11
0
        //Get:Weight Machine Master By Id
        public WeightMachineMaster Get_WeightMachineMasterById(int id)
        {
            WeightMachineMaster w = db.WeightMachineMasters.FirstOrDefault(x => x.Id == id && x.IsDeleted == false);

            return(w);
        }
Ejemplo n.º 12
0
        //Save Excel Data To the Server
        public string SaveDataToServer(DataSet ds)
        {
            string result = string.Empty;

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                string    connection = ConfigurationManager.ConnectionStrings["AveryDBConnectionString"].ConnectionString;
                DataTable dt         = ds.Tables[0];
                int       _failed    = 0;
                int       _success   = 0;
                int       _update    = 0;

                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        string   _PlantCode         = dr["Plant Code"].ToString();
                        string   _MachineId         = dr["Machine Id"].ToString();
                        string   _capacity          = dr["Capacity"].ToString();
                        string   _resolution        = dr["Resolution"].ToString();
                        string   _model             = dr["Model"].ToString();
                        string   _platformsize      = dr["Platform Size"].ToString();
                        string   _machinno          = dr["Machin No"].ToString();
                        string   _indicator         = dr["Indicator"].ToString();
                        string   _lctype            = dr["LC Type"].ToString();
                        string   _noofloadcells     = dr["No Of Load Cells"].ToString();
                        string   _loadcellserialnos = dr["Load Cell Serial Nos"].ToString();
                        string   _Equipment         = dr["Equipment"].ToString();
                        string   _invoiceno         = dr["Invoice No"].ToString();
                        DateTime?_despatchdate      = null;
                        _despatchdate = Convert.ToDateTime(dr["Despatch Date"]);
                        DateTime?_installationdate         = Convert.ToDateTime(dr["Installation Date"]);
                        DateTime?_warrantydate             = Convert.ToDateTime(dr["Warranty Upto"]);
                        string   _reasonofwarrantyuptodate = dr["Reason Of Warranty"].ToString();
                        var      _wt          = db.WeightMachineMasters.Where(x => x.MachineId == _MachineId && x.IsDeleted == false).FirstOrDefault();
                        var      _PlantMaster = db.PlantMasters.Where(x => x.PlantCode == _PlantCode && x.IsDeleted == false).FirstOrDefault();
                        if (_wt != null)
                        {
                            if (_PlantMaster == null && string.IsNullOrEmpty(_MachineId) && string.IsNullOrEmpty(_capacity) &&
                                string.IsNullOrEmpty(_resolution) && string.IsNullOrEmpty(_model) && string.IsNullOrEmpty(_platformsize) &&
                                string.IsNullOrEmpty(_machinno) && string.IsNullOrEmpty(_indicator) && string.IsNullOrEmpty(_lctype) &&
                                string.IsNullOrEmpty(_noofloadcells) && string.IsNullOrEmpty(_loadcellserialnos) &&
                                string.IsNullOrEmpty(_Equipment) && string.IsNullOrEmpty(_invoiceno) && _despatchdate == null && _installationdate == null &&
                                _warrantydate == null && string.IsNullOrEmpty(_reasonofwarrantyuptodate))
                            {
                                _failed++;
                            }
                            else
                            {
                                _wt.PlantCodeId            = _PlantCode;
                                _wt.Capacity               = _capacity;
                                _wt.Resolution             = _resolution;
                                _wt.Model                  = _model;
                                _wt.PlatformSize           = _platformsize;
                                _wt.MachineNo              = _machinno;
                                _wt.Indicator              = _indicator;
                                _wt.LCType                 = _lctype;
                                _wt.NoOfLoadCells          = _noofloadcells;
                                _wt.LoadCellSerialNos      = _loadcellserialnos;
                                _wt.EquipmentId            = Convert.ToInt32(_Equipment);
                                _wt.InvoiceNo              = _invoiceno;
                                _wt.DespatchDate           = _despatchdate;
                                _wt.InstallationDate       = _installationdate;
                                _wt.WarrentyUpto           = _warrantydate;
                                _wt.ReasonWarrentyUptoDate = _reasonofwarrantyuptodate;
                                db.SubmitChanges();
                                _update++;
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(_PlantCode) && _PlantMaster != null && !string.IsNullOrEmpty(_MachineId) &&
                                !string.IsNullOrEmpty(_capacity) && !string.IsNullOrEmpty(_resolution) && !string.IsNullOrEmpty(_model) &&
                                !string.IsNullOrEmpty(_machinno) && !string.IsNullOrEmpty(_indicator) && !string.IsNullOrEmpty(_lctype) &&
                                !string.IsNullOrEmpty(_noofloadcells) && !string.IsNullOrEmpty(_loadcellserialnos) &&
                                !string.IsNullOrEmpty(_Equipment) && !string.IsNullOrEmpty(_invoiceno) && _despatchdate != null &&
                                _installationdate != null && _warrantydate != null && !string.IsNullOrEmpty(_platformsize) &&
                                !string.IsNullOrEmpty(_reasonofwarrantyuptodate))
                            {
                                WeightMachineMaster _mm = db.WeightMachineMasters.Where(x => x.MachineId == _MachineId && x.IsDeleted == false).FirstOrDefault();
                                if (_mm != null)
                                {
                                    _failed++;
                                }
                                else
                                {
                                    db.WeightMachineMasters.InsertOnSubmit(new WeightMachineMaster
                                    {
                                        PlantCodeId            = _PlantCode,
                                        MachineId              = _MachineId,
                                        Capacity               = _capacity,
                                        Resolution             = _resolution,
                                        Model                  = _model,
                                        PlatformSize           = _platformsize,
                                        MachineNo              = _machinno,
                                        Indicator              = _indicator,
                                        LCType                 = _lctype,
                                        NoOfLoadCells          = _noofloadcells,
                                        LoadCellSerialNos      = _loadcellserialnos,
                                        EquipmentId            = Convert.ToInt16(_Equipment),
                                        InvoiceNo              = _invoiceno,
                                        DespatchDate           = _despatchdate,
                                        InstallationDate       = _installationdate,
                                        WarrentyUpto           = _warrantydate,
                                        ReasonWarrentyUptoDate = _reasonofwarrantyuptodate,
                                        IsDeleted              = false
                                    });
                                    db.SubmitChanges();
                                    _success++;
                                }
                            }
                            else
                            {
                                _failed++;
                            }
                        }
                    }
                    catch { _failed++; }
                }
                result = "New Added: " + _success + "  Updated:  " + _update + "  Failed:  " + _failed + "";
            }
            return(result);
        }