Exemple #1
0
            /// <summary>
            /// 获取输入参数
            /// </summary>
            /// <returns></returns>
            public string GetInput()
            {
                string input = "";

                //43
                input += TransType;
                input += ReceiptNo.PadLeft(6);
                input += CardNumber.PadRight(19);
                input += "".PadLeft(4);
                input += TransAmount.PadLeft(12, '0');

                //30
                input += TransDate;
                input += TransTime;
                input += "".PadLeft(6);
                input += "".PadLeft(8);
                input += "".PadLeft(2);

                //71
                input += "".PadLeft(8);
                input += "".PadLeft(15);
                input += "".PadLeft(12);
                input += "".PadLeft(6);
                input += HISLSH.PadLeft(30);
                return(input);
            }
 public override int GetHashCode()
 {
     if (ReceiptNo != null)
     {
         return(ReceiptNo.GetHashCode());
     }
     else
     {
         return(base.GetHashCode());
     }
 }
Exemple #3
0
        private async Task SaveToDatabaseCommandEvent()
        {
            if (await Validation())
            {
                RegisterModel registerModel = new RegisterModel()
                {
                    ID = ReceiptNo.ToUpper(),
                    RegisteredByGroup      = Constants.GroupName.ToUpper(),
                    RegisteredBy           = Constants.UserName.ToUpper(),
                    PrimaryContactNumber   = PrimaryContactNumber,
                    SecondaryContactNumber = SecondaryContactNumber,
                    Email                = EmailAddress,
                    Category             = SelectedCategory.Name.ToUpper(),
                    SubCategory          = SelectedSubGategory.Name.ToUpper(),
                    EventName            = SelectedEvent.Name.ToUpper(),
                    ParticipantName      = ParticipantName.ToUpper(),
                    NumberOfParticipants = NumberOfParticipants,
                    FeesCharged          = Fees,
                    RegistrationDate     = DateTime.Now.Date.ToString("MM/dd/yyyy"),
                    PUBGID               = PUBGID,
                };
                string _collegeName = string.Empty;
                if (IsNonIUCollege)
                {
                    if (IsOtherCollege)
                    {
                        _collegeName = OtherCollege;
                    }
                    else
                    {
                        _collegeName = SelectedCollege;
                    }
                }
                else
                {
                    _collegeName = "INDUS UNIVERSITY";
                }
                if (IsNonIUCollege)
                {
                    if (IsOtherCollege)
                    {
                        _collegeName = OtherCollege;
                    }
                    else
                    {
                        _collegeName = SelectedCollege;
                    }
                }
                else
                {
                    _collegeName = "INDUS UNIVERSITY";
                }
                registerModel.CollgeName = _collegeName;


                try
                {
                    await App.Database.SaveItemAsync(registerModel);

                    ResetCommandEvent();
                    await base.View.DisplayAlert("Save", "Registered successfully", "Ok");
                }
                catch (Exception ex)
                {
                    if (ex.Message.ToLower() == "constraint")
                    {
                        await base.View.DisplayAlert("Save", "Receipt number already exist", "Ok");
                    }
                    else
                    {
                        await base.View.DisplayAlert("Save", ex.Message, "Ok");
                    }
                }
            }
        }
Exemple #4
0
        private void Post_Click(object sender, EventArgs e)
        {
            //check if all necessary fields are there, and valid.
            //username

            //ReceiptNo
            if (ReceiptNo.Text == "")
            {
                MessageBox.Show("Invalid Receipt Number!");
                ReceiptNo.Focus();
            }
            if (SlapMark.Text == "")
            {
                MessageBox.Show("Invalid Slap Mark!");
                SlapMark.Focus();
            }
            if (CarcassType.Text == "")
            {
                MessageBox.Show("Invalid Carcass Type!");
                CarcassType.Focus();
            }

            if (MeatPercent.Text == "")
            {
                MessageBox.Show("Invalid Meat Percent!");
                MeatPercent.Focus();
            }

            using (SqlConnection conn = new SqlConnection(_connectionString))

            {
                CType = new string(CarcassType.Text.Take(5).ToArray());
                String q3 = "SELECT COUNT (ID) FROM [dbo].[SlaughterData] WHERE ReceiptNo ='" + ReceiptNo.Text + "'AND ItemNo ='" + CType + "'";
                using (SqlCommand cmd = new SqlCommand(q3, conn))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error 5");
                        return;
                    }
                    try
                    {
                        Sqty = (int)cmd.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error 6");
                        return;
                    }
                }

                conn.Close();
            }
            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                //transcoding from from carcass code to livestock code to look up in the receipt ledger


                if (CType == "G0110")
                {
                    CType = "G0101";
                }
                if (CType == "G0111")
                {
                    CType = "G0102";
                }
                if (CType == "G0113")
                {
                    CType = "G0104";
                }



                String q = "SELECT sum(convert(int, ReceivedQty) )from dbo.Receipts where ReceiptNo ='" + ReceiptNo.Text + "'AND ItemNo='" + CType + "'";
                //MessageBox.Show(q);
                using (SqlCommand cmd = new SqlCommand(q, conn))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error7");
                        return;
                    }

                    try
                    {
                        Rqty = (int)cmd.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Error3");
                        return;
                    }
                }
                conn.Close();
            }


            if (Rqty > Sqty)
            {
                using (SqlConnection conn = new SqlConnection(_connectionString))
                {
                    string Slap  = SlapMark.Text;
                    string VNo   = VendorNo.Text;
                    string VName = VendorName.Text;
                    string MPC   = MeatPercent.Text;
                    string CCode = ClassificationCode.Text;
                    string RNo   = ReceiptNo.Text;
                    CType = new string(CarcassType.Text.Take(5).ToArray());

                    //insert the record
                    String q5 = "INSERT INTO [dbo].[SlaughterData]([SlaughterTime],[UserID],[ReceiptNo],[ItemNo],[StockWeight],[MeatPercent],[Classification Code])" +
                                "VALUES ('" + DateTime.Now + "','"
                                + User.Text + "','"
                                + RNo + "','"
                                + CType + "','"
                                + NT + "','"
                                + MPC + "','"
                                + ClassificationCode.Text + "')";
                    using (SqlCommand cmd = new SqlCommand(q5, conn))
                    {
                        try
                        {
                            conn.Open();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message + "Error 8");
                            return;
                        }
                        try
                        {
                            cmd.ExecuteNonQuery();
                            MessageBox.Show("Record Posted");
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message + "Error 11");
                        }
                        conn.Close();
                    }


                    if ((Rqty - Sqty) == 1)
                    {
                        if (CType == "G0110")
                        {
                            CType = "G0101";
                        }
                        if (CType == "G0111")
                        {
                            CType = "G0102";
                        }
                        if (CType == "G0113")
                        {
                            CType = "G0104";
                        }
                        //
                        String q6 = "UPDATE [dbo].[Receipts] SET [Slaughtered]='1'  WHERE ReceiptNo='" + RNo + "'AND ItemNo ='" + CType + "'";

                        using (SqlCommand cmd = new SqlCommand(q6, conn))
                        {
                            try
                            {
                                conn.Open();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + "Error 12");
                                return;
                            }
                            try
                            {
                                cmd.ExecuteNonQuery();
                                this.initComBo();
                                ReceiptNo.Text           = "";
                                SlapMark.Text            = "";
                                ReceiptNo.SelectedText   = "";
                                SlapMark.SelectedText    = "";
                                VendorName.Text          = "";
                                VendorNo.Text            = "";
                                CarcassType.Text         = "";
                                CarcassType.SelectedText = "";
                                MeatPercent.Text         = "";
                                ClassificationCode.Text  = "";
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message + "Error 10");
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("The record could not be posted. The slaughtered qty exceeds the received qty for that animal type");
                return;
            }
        }
Exemple #5
0
        public Form1()
        {
            InitializeComponent();
            {
                if (!this.readWeight())
                {
                    //focus on ReceiptNo
                    ReceiptNo.Focus();
                }
                else
                {
                    Weight.Text.Remove(0);
                    Weight.ReadOnly = false;
                    Weight.Focus();
                }
                User.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                // Initialize the screen items
                ScaleID.Text     = Properties.Settings.Default.ScaleLID;
                CrateWeight.Text = Properties.Settings.Default.CrateWeight;
                // initialize comboboxes
                this.initComBo();
                try
                {
                    CR = Convert.ToDouble(CrateWeight.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Invalid Format in the crate weight");
                }
                catch (OverflowException)
                {
                    MessageBox.Show("The crate weight is too large");
                }

                try
                {
                    WT = Convert.ToDouble(Weight.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Invalid Format in the Scale reading");
                }
                catch (OverflowException)
                {
                    MessageBox.Show("The scale reading is too large");
                }
                NT = WT - CR;
                //rounding


                var result = NT - Math.Truncate(NT);
                if (result > 0.54)
                {
                    NT = Math.Ceiling(NT);
                }
                else
                {
                    NT = Math.Floor(NT);
                }

                NetWeight.Text = Convert.ToString(NT);
            }
        }